use crate::{
Bytes,
reader::{MidiSource, ReadResult, Reader},
};
#[doc = r#"
Identifies a chunk of a MIDI file that cannot be parsed.
It is up to the user for how to handle such chunks. Typically, these data are
ignored. However, sometimes there are particular use cases for handling
non-standard chunk types. We leave the option up to you.
"#]
#[derive(Clone, Debug, PartialEq)]
pub struct UnknownChunk<'a> {
name: Bytes<'a>,
inner: Bytes<'a>,
}
impl<'a> UnknownChunk<'a> {
pub(crate) fn read<'slc, 'r, R>(name: Bytes<'a>, reader: &'r mut Reader<R>) -> ReadResult<Self>
where
R: MidiSource<'slc>,
'slc: 'a,
{
let length = u32::from_be_bytes(*reader.read_exact_size()?);
let data = reader.read_exact(length as usize)?;
Ok(Self { name, inner: data })
}
pub fn len(&self) -> usize {
self.inner.len()
}
pub fn is_empty(&self) -> bool {
self.inner.is_empty()
}
}