Skip to main content

comindly_api/
manifests.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
4pub struct PackageRow {
5    pub repo: String,
6    /// `pypi` | `npm` | `go` | `cargo`.
7    pub ecosystem: String,
8    /// Normalized package name.
9    pub name: String,
10    /// `true`: this repo publishes the package; `false`: it depends on it.
11    pub publishes: bool,
12    /// Published version, or the declared requirement for a dependency.
13    pub version: Option<String>,
14    /// Version pinned by the lockfile next to the manifest.
15    pub locked: Option<String>,
16    /// Repo-relative manifest path.
17    pub manifest: String,
18}
19
20/// An internal dependency: `consumer` uses `name`, which `publisher` publishes.
21#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
22pub struct InternalDep {
23    pub ecosystem: String,
24    pub name: String,
25    pub publisher: String,
26    pub published: Option<String>,
27    pub consumer: String,
28    pub requirement: Option<String>,
29    pub locked: Option<String>,
30}
31
32impl InternalDep {
33    /// The consumer pins a version other than the one the publisher's source declares.
34    pub fn skewed(&self) -> bool {
35        matches!((&self.locked, &self.published), (Some(l), Some(p)) if l != p)
36    }
37}