pub struct CafChunkReader<T>where
T: Read,{ /* private fields */ }
Implementations§
Source§impl<T> CafChunkReader<T>where
T: Read,
impl<T> CafChunkReader<T>where
T: Read,
Sourcepub fn new(rdr: T) -> Result<Self, CafError>
pub fn new(rdr: T) -> Result<Self, CafError>
Examples found in repository?
13 14 15 16 17 18 19 20 21 22 23 24 25 26
fn main() {
let file_path = env::args().nth(1).expect("No arg found. Please specify a file to open.");
println!("Opening file: {}", file_path);
let f_rdr = File::open(file_path).unwrap();
let mut rdr = CafChunkReader::new(f_rdr).unwrap();
// Dump the decoded packets.
loop {
let chunk = rdr.read_chunk().unwrap();
match chunk {
CafChunk::AudioDataInMemory(..) => println!("Audio data in memory"),
_ => println!("{:?}", chunk),
}
}
}
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Returns the reader that this Reader wraps
Sourcepub fn read_chunk(&mut self) -> Result<CafChunk, CafError>
pub fn read_chunk(&mut self) -> Result<CafChunk, CafError>
Examples found in repository?
13 14 15 16 17 18 19 20 21 22 23 24 25 26
fn main() {
let file_path = env::args().nth(1).expect("No arg found. Please specify a file to open.");
println!("Opening file: {}", file_path);
let f_rdr = File::open(file_path).unwrap();
let mut rdr = CafChunkReader::new(f_rdr).unwrap();
// Dump the decoded packets.
loop {
let chunk = rdr.read_chunk().unwrap();
match chunk {
CafChunk::AudioDataInMemory(..) => println!("Audio data in memory"),
_ => println!("{:?}", chunk),
}
}
}
Sourcepub fn read_chunk_body(
&mut self,
hdr: &CafChunkHeader,
) -> Result<CafChunk, CafError>
pub fn read_chunk_body( &mut self, hdr: &CafChunkHeader, ) -> Result<CafChunk, CafError>
Reads a chunk body into memory and decodes it
Sourcepub fn read_chunk_header(&mut self) -> Result<CafChunkHeader, CafError>
pub fn read_chunk_header(&mut self) -> Result<CafChunkHeader, CafError>
Reads a chunk header
Source§impl<T> CafChunkReader<T>
impl<T> CafChunkReader<T>
Sourcepub fn to_next_chunk(&mut self, hdr: &CafChunkHeader) -> Result<(), CafError>
pub fn to_next_chunk(&mut self, hdr: &CafChunkHeader) -> Result<(), CafError>
Seeks to the next chunk header in the file
It is meant to be called directly after a chunk header has been read, with the internal reader’s position at the start of a chunk’s body. It then seeks to the next chunk header.
With this function you can ignore chunks, not reading them, if they have uninteresting content, or if further knowledge on the file is needed before their content becomes interesting.
Panics if the header’s chunk size is unspecified per spec (==-1). “Skipping” would make no sense here, as it will put you to the end of the file.
Sourcepub fn to_previous_chunk(
&mut self,
hdr: &CafChunkHeader,
) -> Result<(), CafError>
pub fn to_previous_chunk( &mut self, hdr: &CafChunkHeader, ) -> Result<(), CafError>
Seeks to the previous chunk header in the file
It is meant to be called with the internal reader’s position at the end of a chunk’s body. It then seeks to the start of that chunk body.
Panics if the header’s chunk size is unspecified per spec (==-1). “Skipping” would make no sense here, as it will put you to the end of the file.
Sourcepub fn read_chunks_to_mem(
&mut self,
required: Vec<ChunkType>,
content_read: &[ChunkType],
) -> Result<(Vec<CafChunk>, Vec<CafChunkHeader>), CafError>
pub fn read_chunks_to_mem( &mut self, required: Vec<ChunkType>, content_read: &[ChunkType], ) -> Result<(Vec<CafChunk>, Vec<CafChunkHeader>), CafError>
Read chunks from a whitelist to memory
Uses the given CafChunkReader
to read all chunks to memory
whose types are inside the content_read
slice.
Stops as soon as all chunk were encountered with types in the
required
argument list.
As we don’t have support for reading chunks with unspecified length,
you shouldn’t use this function to read audio data to memory.
Generally, reading the audio data chunk to memory is a bad idea
as it may possibly be very big. Instead, use the nice high level
CafPacketReader
struct.