Skip to main content

CollectSink

Struct CollectSink 

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

A sink that collects every final row into one tightly packed image.

begin sizes the buffer; provide_next_buffer hands out the rows in place, so the decoder writes straight into the final image. Final-row coverage is tracked separately: repeated or overlapping strips cannot hide missing rows at finish. The coverage bitmap uses eight bytes per 64 rows (rounded up), independent of image width. Supplying a buffer does not prove that the codec actually wrote every byte; native correctness remains required.

Implementations§

Source§

impl CollectSink

Source

pub fn new() -> Self

An empty sink.

Source

pub fn width(&self) -> u32

Output width, once begin has been called.

Source

pub fn height(&self) -> u32

Output height, once begin has been called.

Source

pub fn descriptor(&self) -> Option<PixelDescriptor>

Output descriptor, once begin has been called.

Source

pub fn rows_written(&self) -> u64

Rows written so far (a row written twice counts twice).

Source

pub fn finished(&self) -> bool

Whether finish has been called.

Source

pub fn bytes(&self) -> &[u8] ⓘ

The collected pixels, tightly packed.

Source

pub fn as_pixel_slice(&self) -> Option<PixelSlice<'_>>

A zero-copy view of the collected image.

Source

pub fn into_buffer(self) -> Option<PixelBuffer>

Take the finished image without copying its pixels or allocating.

Returns None before DecodeRowSink::finish succeeds. Call this only after the driver returns success: a sink’s finish is not proof that the decoder’s later validation succeeded. This does not include metadata; retain the decoder’s completion details separately.

Source

pub fn to_buffer(&self) -> Option<PixelBuffer>

Copy the collected image into an owned [PixelBuffer].

Trait Implementations§

Source§

impl Debug for CollectSink

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl DecodeRowSink for CollectSink

Source§

fn begin( &mut self, width: u32, height: u32, descriptor: PixelDescriptor, ) -> Result<(), SinkError>

Called once before the first strip with total output dimensions and pixel format. Read more
Source§

fn provide_next_buffer( &mut self, y: u32, height: u32, width: u32, descriptor: PixelDescriptor, ) -> Result<PixelSliceMut<'_>, SinkError>

Provide a mutable pixel buffer for decoded rows y .. y + height. Read more
Source§

fn finish(&mut self) -> Result<(), SinkError>

Called once after the last strip has been fully written. Read more
Source§

fn max_buffer_rows(&self) -> NonZero<u32>

Largest strip the sink can lend without growing its admitted storage. Read more
Source§

fn accepts_provisional(&self) -> bool

Whether this sink wants provisional rows from progressive passes. Read more
Source§

fn provide_pass_buffer( &mut self, meta: BatchMeta, height: u32, width: u32, descriptor: PixelDescriptor, ) -> Result<PixelSliceMut<'_>, Box<dyn Error + Send + Sync>>

Provide a buffer for provisional rows meta.y .. meta.y + height of pass meta.pass: an approximation a later pass replaces. Called only on sinks whose accepts_provisional returned true, never for final rows (meta.is_final is false), and in any order relative to other provisional rows. The final rows for the same region still arrive through provide_next_buffer. Read more
Source§

impl Default for CollectSink

Source§

fn default() -> CollectSink

Returns the “default value” for a type. Read more

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.