cargo_resources/
declarations.rs

1use cargo_metadata::camino::Utf8PathBuf;
2use crate::resource_encoding::ResourceEncoding;
3use crate::ResourceName;
4
5/// The structure matching the resource declaration (provides) in the package metadata.
6#[derive(serde::Deserialize, Debug)]
7pub struct ResourceDataDeclaration {
8    /// Whether resource's file encoding is text or binary
9    pub encoding: Option<ResourceEncoding>,
10
11    /// The path of the resource within the crate
12    pub crate_path: Utf8PathBuf,
13
14    /// The path of the resource as a resource
15    pub output_path: Option<Utf8PathBuf>,
16
17    /// The unique name for the resource
18    pub resource_name: Option<ResourceName>
19}
20
21/// The structure matching the resource usage declaration in the consuming package metadata.
22#[derive(serde::Deserialize, Debug)]
23pub struct ResourceConsumerDeclaration {
24    /// The relative path of the resource root from the crate root
25    pub resource_root: Option<Utf8PathBuf>,
26
27    /// The list of required resources
28    pub requires: Option<Vec<ResourceRequirementDeclaration>>
29}
30
31/// The structure matching the resource requirement in the consuming package.
32#[derive(serde::Deserialize, Debug)]
33pub struct ResourceRequirementDeclaration {
34    /// The unique name of the required resource
35    pub resource_name: String,
36
37    /// The optional hex-encoded SHA256 value of the required resource
38    pub required_sha: Option<String>
39}