Reader

Trait Reader 

Source
pub trait Reader {
    // Required methods
    fn position(&mut self) -> u64;
    fn read(&mut self, buf: &mut [u8]) -> Result<usize>;
    fn seek(&mut self, position: u64) -> Result<u64>;
    fn wait_for_file_size(&mut self, target_size: u64) -> ReaderGrowStatus;

    // Provided method
    fn read_exact(&mut self, buf: &mut [u8]) -> Result<()> { ... }
}

Required Methods§

Source

fn position(&mut self) -> u64

Current position, in bytes, inside a source.

Source

fn read(&mut self, buf: &mut [u8]) -> Result<usize>

👎Deprecated since 2.4.0: use ‘read_exact’ method instead.

Pull some bytes from a source into the specified buffer, returning how many bytes were read.

Source

fn seek(&mut self, position: u64) -> Result<u64>

Seek to a position, in bytes, from the start of a source.

Source

fn wait_for_file_size(&mut self, target_size: u64) -> ReaderGrowStatus

Wait until a source will be ready to read bytes to the specified position.

When calling this function, libheif wants to make sure that it can read the file up to target_size. This is useful when the file is currently downloaded and may grow with time. You may, for example, extract the image sizes even before the actual compressed image data has been completely downloaded.

Even if your input files do not grow, you will have to implement at least detection whether the target_size is above the (fixed) file length (in this case, return ‘ReaderGrowStatus::SizeBeyondEof’).

Provided Methods§

Source

fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>

Pull bytes from a source into the specified buffer.

Implementors§

Source§

impl<T> Reader for StreamReader<T>
where T: Read + Seek,