use symphonia_core::errors::Result;
use symphonia_core::io::ReadBytes;
use symphonia_core::meta::MetadataRevision;
use crate::atoms::{Atom, AtomHeader, AtomIterator, AtomType, MetaAtom};
#[derive(Debug)]
pub struct UdtaAtom {
header: AtomHeader,
pub meta: Option<MetaAtom>,
}
impl UdtaAtom {
pub fn take_metadata(&mut self) -> Option<MetadataRevision> {
self.meta.as_mut().and_then(|meta| meta.take_metadata())
}
}
impl Atom for UdtaAtom {
fn header(&self) -> AtomHeader {
self.header
}
#[allow(clippy::single_match)]
fn read<B: ReadBytes>(reader: &mut B, header: AtomHeader) -> Result<Self> {
let mut iter = AtomIterator::new(reader, header);
let mut meta = None;
while let Some(header) = iter.next()? {
match header.atype {
AtomType::Meta => {
meta = Some(iter.read_atom::<MetaAtom>()?);
}
_ => (),
}
}
Ok(UdtaAtom { header, meta })
}
}