forge
Explore
Log in

Don't you dare go Hollow

forge

Clone
★ 0

0 watching0 forksRustAGPL-3.07.1 MiB490f099Tahinli7 hours ago322 commits

packages.rs89 lines, 2.9 KiBHistoryRawDownload
1//! Package registries. An owner (user or org) holds packages of one `kind`; each package has
2//! versions. The stored shape is in migrations/0061_packages.sql, the store functions in
3//! store/packages.rs. Bytes of a `.crate` live in blob storage under `packages/<version id>`;
4//! only metadata is stored here. Kinds are `cargo` and `oci` (container images).
5
6/// The Cargo registry kind.
7pub const KIND_CARGO: &str = "cargo";
8/// The container registry kind. Its packages are images; their tags and manifests are in the
9/// `oci_*` tables (migrations/0062_oci.sql), not in `package_versions`.
10pub const KIND_OCI: &str = "oci";
11
12/// A package. `name_key` is the lowercase name the index uses; `private` hides the package and
13/// its index from everyone but the owner's members.
14#[derive(Debug, Clone, PartialEq, Eq)]
15pub struct Package {
16 pub id: String,
17 pub owner_id: String,
18 pub kind: String,
19 pub name: String,
20 pub name_key: String,
21 pub repo_id: Option<String>,
22 pub private: bool,
23 pub created_at: String,
24 pub updated_at: String,
25}
26
27/// One published version of a package.
28#[derive(Debug, Clone, PartialEq, Eq)]
29pub struct PackageVersion {
30 pub id: String,
31 pub package_id: String,
32 pub version: String,
33 pub yanked: bool,
34 /// Lowercase hex sha256 of the `.crate` file.
35 pub checksum: String,
36 pub size: u64,
37 /// The index line as published, with `yanked` false. Served with the current yank state.
38 pub index_json: String,
39 pub description: Option<String>,
40 pub readme: Option<String>,
41 pub publisher_id: String,
42 pub created_at: String,
43}
44
45/// A package with what its list shows: how many versions it has and the newest one.
46#[derive(Debug, Clone, PartialEq, Eq)]
47pub struct PackageSummary {
48 pub package: Package,
49 pub version_count: u64,
50 pub latest_version: Option<String>,
51 pub latest_description: Option<String>,
52}
53
54/// Input for `Store::publish_package_version`.
55#[derive(Debug, Clone, Copy)]
56pub struct NewPackageVersion<'a> {
57 pub package_id: &'a str,
58 pub version: &'a str,
59 pub checksum: &'a str,
60 pub size: u64,
61 pub index_json: &'a str,
62 pub description: Option<&'a str>,
63 pub readme: Option<&'a str>,
64 pub publisher_id: &'a str,
65}
66
67/// A container manifest as pushed. `content` is the exact JSON, so its digest still checks.
68#[derive(Debug, Clone, PartialEq, Eq)]
69pub struct OciManifest {
70 pub id: String,
71 pub package_id: String,
72 pub digest: String,
73 pub media_type: String,
74 pub content: String,
75 /// The image's config and layers in bytes, or the manifest's length for an index.
76 pub size: u64,
77 pub created_at: String,
78}
79
80/// One tag of a container image, with the manifest it points at.
81#[derive(Debug, Clone, PartialEq, Eq)]
82pub struct OciTag {
83 pub tag: String,
84 pub digest: String,
85 pub media_type: String,
86 pub size: u64,
87 pub created_at: String,
88 pub updated_at: String,
89}