Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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