Skip to content

Commit 4e8014f

Browse files
committed
feat(schemas): add PackageList message schema
This is is for `cargo package --list` in JSON format
1 parent 02226ae commit 4e8014f

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

crates/cargo-util-schemas/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
1111
pub mod core;
1212
pub mod manifest;
13+
pub mod messages;
1314
#[cfg(feature = "unstable-schema")]
1415
pub mod schema;
1516

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//! Schemas for JSON messages emitted by Cargo.
2+
3+
use std::collections::BTreeMap;
4+
use std::path::PathBuf;
5+
6+
/// File information of a package archive generated by `cargo package --list`.
7+
#[derive(Debug, serde::Serialize)]
8+
#[serde(rename_all = "snake_case")]
9+
pub struct PackageList {
10+
/// The Package ID Spec of the package.
11+
pub id: crate::core::PackageIdSpec,
12+
/// A map of relative paths in the archive to their detailed file information.
13+
pub files: BTreeMap<PathBuf, PackageFile>,
14+
}
15+
16+
/// Where the file is from.
17+
#[derive(Debug, serde::Serialize)]
18+
#[serde(rename_all = "snake_case", tag = "kind")]
19+
pub enum PackageFile {
20+
/// File being copied from another location.
21+
Copy {
22+
/// An absolute path to the actual file content
23+
path: PathBuf,
24+
},
25+
/// File being generated during packaging
26+
Generate {
27+
/// An absolute path to the original file the generated one is based on.
28+
/// if any.
29+
#[serde(skip_serializing_if = "Option::is_none")]
30+
path: Option<PathBuf>,
31+
},
32+
}

0 commit comments

Comments
 (0)