Skip to main content

Source

Trait Source 

Source
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§

Source

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§

Source

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".

Implementors§

Source§

impl<R> Source for R
where R: Read + Send,

Source§

impl<S> Source for Prefixed<S>
where S: Source,