pub trait Source: Send {
// Required method
fn read(&mut self, buf: &mut [u8]) -> Result<usize, PixelsError>;
// Provided method
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), PixelsError> { ... }
}Expand description
A forward-only source of bytes.
Implementors need not support seeking, and the engine never asks them to. Sources perform no decoding and allocate nothing proportional to image size.
Required Methods§
Sourcefn read(&mut self, buf: &mut [u8]) -> Result<usize, PixelsError>
fn read(&mut self, buf: &mut [u8]) -> Result<usize, PixelsError>
Read into buf, returning the number of bytes read.
Returning Ok(0) means end of input. A short read is not an error: the
engine calls again until it has what it needs or the source ends.
§Errors
Returns PixelsError::Io if the underlying reader fails.
Provided Methods§
Sourcefn read_exact(&mut self, buf: &mut [u8]) -> Result<(), PixelsError>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), PixelsError>
Fill buf completely.
§Errors
Returns PixelsError::Io on reader failure, or
PixelsError::Malformed if the source ends before buf is full —
a truncated stream is malformed input, not an I/O fault.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".