pub trait Encoder {
// Required method
fn encode(
&self,
pixels: &[u8],
dims: Dimensions,
out: &mut Vec<u8>,
) -> Result<usize>;
}Expand description
Encodes an in-memory image into a compressed byte stream.
Implementations append the encoded bytes to out rather than allocating a fresh buffer,
keeping hot paths allocation-conscious for callers that reuse a scratch buffer.
Required Methods§
Sourcefn encode(
&self,
pixels: &[u8],
dims: Dimensions,
out: &mut Vec<u8>,
) -> Result<usize>
fn encode( &self, pixels: &[u8], dims: Dimensions, out: &mut Vec<u8>, ) -> Result<usize>
Encode pixels (described by dims) into out, returning the number of bytes written.
§Errors
Returns Error::InvalidInput if pixels does not match dims, or
Error::Unsupported if the requested configuration is not implemented.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".