mp4_atom/meta/properties/
auxc.rs1use crate::*;
2
3#[derive(Debug, Clone, PartialEq, Eq, Default)]
7#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8pub struct Auxc {
9 pub aux_type: String,
10 pub aux_subtype: Vec<u8>,
11}
12
13impl AtomExt for Auxc {
14 type Ext = ();
15
16 const KIND_EXT: FourCC = FourCC::new(b"auxC");
17
18 fn decode_body_ext<B: Buf>(buf: &mut B, _ext: ()) -> Result<Self> {
19 let aux_type = String::decode(buf)?;
20 let aux_subtype = Vec::decode(buf)?;
21 Ok(Auxc {
22 aux_type,
23 aux_subtype,
24 })
25 }
26
27 fn encode_body_ext<B: BufMut>(&self, buf: &mut B) -> Result<()> {
28 self.aux_type.as_str().encode(buf)?;
29 self.aux_subtype.encode(buf)?;
30 Ok(())
31 }
32}
33
34#[cfg(test)]
35mod tests {
36 use std::vec;
37
38 use super::*;
39
40 #[test]
41 fn test_auxc() {
42 let expected = Auxc {
43 aux_type: "something".to_string(),
44 aux_subtype: vec![3, 2, 1],
45 };
46 let mut buf = Vec::new();
47 expected.encode(&mut buf).unwrap();
48
49 let mut buf = buf.as_ref();
50 let decoded = Auxc::decode(&mut buf).unwrap();
51 assert_eq!(decoded, expected);
52 }
53}