pub struct EncoderSink<E> { /* private fields */ }Expand description
DecodeRowSink that feeds an Encoder.
begin declares the image to the encoder (Encoder::begin); an
encoder that answers with a streaming OutputTiming writes its header
at once and makes bytes available as rows arrive.
output_timing reports that answer.
provide_next_buffer returns the sink’s own strip buffer, so the
decoder writes straight into the bytes the encoder reads; the strip is
pushed on the next provide_next_buffer or on finish. No pixel is
copied by this handoff; the encoder may copy or retain its own input/state.
Drain encoded bytes between decode steps with
pending_output and
consume_output to keep output memory bounded.
That bounds queued encoded bytes only. Awaiting a slow writer can keep
much larger raw/intermediate allocations alive; output timing alone does
not establish when those allocations are released.
Encoder errors reach the decoder’s caller as the sink error, typed, so
they can be told apart from malformed input.
Implementations§
Source§impl<E: Encoder> EncoderSink<E>
impl<E: Encoder> EncoderSink<E>
Sourcepub fn output_timing(&self) -> Option<OutputTiming>
pub fn output_timing(&self) -> Option<OutputTiming>
Sourcepub fn rows_pushed(&self) -> u64
pub fn rows_pushed(&self) -> u64
Rows pushed into the encoder so far.
Sourcepub fn pending_output(&self) -> &[u8] ⓘ
pub fn pending_output(&self) -> &[u8] ⓘ
Encoded bytes ready to send; see Encoder::pending_output.
Sourcepub fn consume_output(&mut self, n: usize)
pub fn consume_output(&mut self, n: usize)
Mark the first n pending bytes as sent.
Sourcepub fn take_output(&mut self, into: &mut Vec<u8>)
pub fn take_output(&mut self, into: &mut Vec<u8>)
Append every pending byte to into and consume it; see
Encoder::take_output.
Sourcepub fn write_pending(&mut self, w: &mut impl Write) -> Result<usize>
pub fn write_pending(&mut self, w: &mut impl Write) -> Result<usize>
Write every pending byte to w. Returns how many were written.
Sourcepub fn finish(self) -> Result<EncodeOutput, EncoderSinkError<E::Error>>
pub fn finish(self) -> Result<EncodeOutput, EncoderSinkError<E::Error>>
Push any pending strip and finish the encoder. Returns the bytes not
already taken through consume_output.
Trait Implementations§
Source§impl<E: Encoder> Debug for EncoderSink<E>
impl<E: Encoder> Debug for EncoderSink<E>
Source§impl<E: Encoder> DecodeRowSink for EncoderSink<E>
impl<E: Encoder> DecodeRowSink for EncoderSink<E>
Source§fn begin(
&mut self,
width: u32,
height: u32,
descriptor: PixelDescriptor,
) -> Result<(), SinkError>
fn begin( &mut self, width: u32, height: u32, descriptor: PixelDescriptor, ) -> Result<(), SinkError>
Source§fn provide_next_buffer(
&mut self,
_y: u32,
height: u32,
width: u32,
descriptor: PixelDescriptor,
) -> Result<PixelSliceMut<'_>, SinkError>
fn provide_next_buffer( &mut self, _y: u32, height: u32, width: u32, descriptor: PixelDescriptor, ) -> Result<PixelSliceMut<'_>, SinkError>
y .. y + height. Read moreSource§fn finish(&mut self) -> Result<(), SinkError>
fn finish(&mut self) -> Result<(), SinkError>
Source§fn max_buffer_rows(&self) -> NonZero<u32>
fn max_buffer_rows(&self) -> NonZero<u32>
Source§fn accepts_provisional(&self) -> bool
fn accepts_provisional(&self) -> bool
Source§fn provide_pass_buffer(
&mut self,
meta: BatchMeta,
height: u32,
width: u32,
descriptor: PixelDescriptor,
) -> Result<PixelSliceMut<'_>, Box<dyn Error + Send + Sync>>
fn provide_pass_buffer( &mut self, meta: BatchMeta, height: u32, width: u32, descriptor: PixelDescriptor, ) -> Result<PixelSliceMut<'_>, Box<dyn Error + Send + Sync>>
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