cargo_util_schemas/
messages.rs

1//! Schemas for JSON messages emitted by Cargo.
2
3use std::collections::BTreeMap;
4use 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")]
9pub 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")]
19pub 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}