Skip to content

Commit

Permalink
added image_data methods
Browse files Browse the repository at this point in the history
  • Loading branch information
saecki committed Nov 24, 2020
1 parent 2950dd5 commit ab640ec
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mp4ameta"
version = "0.7.0"
version = "0.7.1"
authors = ["Saecki <tobiasschmitz2001@gmail.com>"]
license = "MIT OR Apache-2.0"
readme = "README.md"
Expand Down
30 changes: 30 additions & 0 deletions src/core/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,36 @@ impl Data {
}
}

/// Returns a byte vec reference if `self` is of type [`Data::Jpeg`](crate::Data::Jpeg)
/// or [`Data::Png`](crate::Data::Png).
pub const fn image_data(&self) -> Option<&Vec<u8>> {
match self {
Self::Jpeg(v) => Some(v),
Self::Png(v) => Some(v),
_ => None,
}
}

/// Returns a mutable byte vec reference if `self` is of type [`Data::Jpeg`](crate::Data::Jpeg)
/// or [`Data::Png`](crate::Data::Png).
pub fn image_data_mut(&mut self) -> Option<&mut Vec<u8>> {
match self {
Self::Jpeg(v) => Some(v),
Self::Png(v) => Some(v),
_ => None,
}
}

/// Consumes `self` and returns a byte vec if `self` is of type [`Data::Jpeg`](crate::Data::Jpeg)
/// or [`Data::Png`](crate::Data::Png).
pub fn take_image_data(self) -> Option<Vec<u8>> {
match self {
Self::Jpeg(v) => Some(v),
Self::Png(v) => Some(v),
_ => None,
}
}

/// Returns a byte vec reference if `self` is of type [`Data::Reserved`](crate::Data::Reserved).
pub const fn reserved(&self) -> Option<&Vec<u8>> {
match self {
Expand Down

0 comments on commit ab640ec

Please sign in to comment.