caf

Struct CafChunkReader

Source
pub struct CafChunkReader<T>
where T: Read,
{ /* private fields */ }

Implementations§

Source§

impl<T> CafChunkReader<T>
where T: Read,

Source

pub fn new(rdr: T) -> Result<Self, CafError>

Examples found in repository?
examples/tool.rs (line 17)
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),
		}
	}
}
Source

pub fn into_inner(self) -> T

Returns the reader that this Reader wraps

Source

pub fn read_chunk(&mut self) -> Result<CafChunk, CafError>

Examples found in repository?
examples/tool.rs (line 20)
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),
		}
	}
}
Source

pub fn read_chunk_body( &mut self, hdr: &CafChunkHeader, ) -> Result<CafChunk, CafError>

Reads a chunk body into memory and decodes it

Source

pub fn read_chunk_header(&mut self) -> Result<CafChunkHeader, CafError>

Reads a chunk header

Source§

impl<T> CafChunkReader<T>
where T: Read + Seek,

Source

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.

Source

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.

Source

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.

Auto Trait Implementations§

§

impl<T> Freeze for CafChunkReader<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for CafChunkReader<T>
where T: RefUnwindSafe,

§

impl<T> Send for CafChunkReader<T>
where T: Send,

§

impl<T> Sync for CafChunkReader<T>
where T: Sync,

§

impl<T> Unpin for CafChunkReader<T>
where T: Unpin,

§

impl<T> UnwindSafe for CafChunkReader<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.