BytesEncoder

Struct BytesEncoder 

Source
pub struct BytesEncoder { /* private fields */ }
Expand description

Encoder for raw byte input with explicit pixel layout.

This encoder wraps StreamingEncoder to provide true streaming encoding without buffering the entire image in memory.

Implementations§

Source§

impl BytesEncoder

Source

pub fn push( &mut self, data: &[u8], rows: usize, stride_bytes: usize, stop: impl Stop, ) -> Result<()>

Push rows with explicit stride.

  • data: Raw pixel bytes
  • rows: Number of scanlines to push
  • stride_bytes: Bytes per row in buffer (>= width * bytes_per_pixel)
  • stop: Cancellation token (use enough::Unstoppable if not needed)
Source

pub fn push_packed(&mut self, data: &[u8], stop: impl Stop) -> Result<()>

Push contiguous (packed) data.

Stride is assumed to be width * bytes_per_pixel. Rows inferred from data.len() / (width * bytes_per_pixel).

Source

pub fn width(&self) -> u32

Get image width.

Source

pub fn height(&self) -> u32

Get image height.

Source

pub fn rows_pushed(&self) -> u32

Get number of rows pushed so far.

Source

pub fn rows_remaining(&self) -> u32

Get number of rows remaining.

Source

pub fn layout(&self) -> PixelLayout

Get the pixel layout.

Source

pub fn finish(self) -> Result<Vec<u8>>

Finish encoding, return JPEG bytes.

Source

pub fn finish_to<W: Write>(self, output: W) -> Result<W>

Finish encoding to Write destination.

Source

pub fn finish_to_vec(self, output: &mut Vec<u8>) -> Result<()>

Finish encoding, appending JPEG bytes to an existing Vec.

Useful for no_std environments or buffer reuse.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.