Skip to content

Commit

Permalink
Expose manifest and its files from metadata API
Browse files Browse the repository at this point in the history
  • Loading branch information
YDX-2147483647 committed Sep 29, 2023
1 parent 82c3a89 commit 1a04052
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/file/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ impl Metadata {
}
}

/// Get the files manifest
pub fn manifest(&self) -> Option<&Manifest> {
match self {
Metadata::V2 { .. } => None,
Metadata::V3 { manifest, .. } => Some(&manifest),
}
}

/// Get the input vector if set.
///
/// For Firefox Send v3 and above `None` is returned as no input vector is used.
Expand Down Expand Up @@ -145,21 +153,26 @@ impl Manifest {
pub fn from_file(name: String, mime: String, size: u64) -> Self {
Self::from(vec![ManifestFile::from(name, mime, size)])
}

// Get files part of the share
pub fn files<'a>(self: &'a Self) -> &'a Vec<ManifestFile> {
&self.files
}
}

/// Metadata manifest file, used in Send v3.
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct ManifestFile {
/// The file name.
name: String,
pub name: String,

/// The file mimetype.
/// TODO: can we use the `Mime` type here?
#[serde(rename = "type")]
mime: String,

/// The file size.
size: u64,
pub size: u64,
}

impl ManifestFile {
Expand Down

0 comments on commit 1a04052

Please sign in to comment.