Skip to main content

ChannelRowSink

Struct ChannelRowSink 

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

A sink that streams finished strips to the async side over a bounded channel. Each strip is an owned [PixelBuffer]; provide_* hands the decoder a fresh strip and ships the previous one, blocking the decode thread while the channel is full, so a slow consumer throttles the decoder instead of the decoder filling memory.

It blocks, so it belongs on a thread outside the runtime: a Compute such as spawn_blocking or a rayon pool, or pull_decode_on_thread. Under Inline the batch runs on a runtime worker, where tokio refuses to block.

Implementations§

Source§

impl ChannelRowSink

Source

pub fn new(tx: Sender<StripEvent>, provisional: bool) -> Self

A sink sending into tx. provisional says whether progressive passes should be forwarded as they arrive.

Source

pub fn with_pulse(self, pulse: SharedPulse) -> Self

Re-check pulse while blocked on a full channel, so a cancelled decode is not held hostage by a consumer that stopped consuming.

Trait Implementations§

Source§

impl Debug for ChannelRowSink

Source§

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

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

impl DecodeRowSink for ChannelRowSink

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 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<'_>, SinkError>

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§

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

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.