diff --git a/Cargo.toml b/Cargo.toml index b7af034..3593142 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mp4ameta" -version = "0.7.0" +version = "0.7.1" authors = ["Saecki "] license = "MIT OR Apache-2.0" readme = "README.md" diff --git a/src/core/data.rs b/src/core/data.rs index fc4855c..7d3cc6b 100644 --- a/src/core/data.rs +++ b/src/core/data.rs @@ -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> { + 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> { + 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> { + 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> { match self {