mp4_atom/mdat.rs
1use crate::*;
2
3/// A media data atom.
4///
5/// I would not recommend using this for large files, as it requires the entire file is loaded into memory.
6/// Instead, use [ReadFrom] to read the [Header] first followed by the mdat data.
7#[derive(Debug, Clone, PartialEq)]
8#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9pub struct Mdat {
10 pub data: Vec<u8>,
11}
12
13impl Atom for Mdat {
14 const KIND: FourCC = FourCC::new(b"mdat");
15
16 fn decode_body<B: Buf>(buf: &mut B) -> Result<Self> {
17 Ok(Mdat {
18 data: Vec::decode(buf)?,
19 })
20 }
21
22 fn encode_body<B: BufMut>(&self, buf: &mut B) -> Result<()> {
23 self.data.encode(buf)
24 }
25}