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§
Sourcefn read(&mut self, buf: &mut [u8]) -> Result<usize>
👎Deprecated since 2.4.0: use ‘read_exact’ method instead.
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
Pull some bytes from a source into the specified buffer, returning how many bytes were read.
Sourcefn seek(&mut self, position: u64) -> Result<u64>
fn seek(&mut self, position: u64) -> Result<u64>
Seek to a position, in bytes, from the start of a source.
Sourcefn wait_for_file_size(&mut self, target_size: u64) -> ReaderGrowStatus
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§
Sourcefn read_exact(&mut self, buf: &mut [u8]) -> Result<()>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>
Pull bytes from a source into the specified buffer.