Skip to main content

Consumer

Struct Consumer 

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

Consume a group, frame-by-frame.

Usually a view of one Producer, but a group served across a route change is spliced: it reads each contributing route’s copy in turn, joined at the frame the takeover happened on, so the reader never sees the seam.

Implementations§

Source§

impl Consumer

Source

pub fn keep_alive(&self)

Mark the group as still being read, so a slow batch drain does not expire it.

Source

pub fn timescale(&self) -> Timescale

The parent track’s timescale.

Source

pub fn index(&self) -> u64

The index of the next frame this consumer will return.

Starts at 0, or at the group’s first available frame once Self::set_frames has clamped it, and advances by one per frame read.

Source

pub fn set_frames(&mut self, frames: impl RangeBounds<u64>)

Limit subsequent reads to these frame indices without rewinding read progress.

2..=5 includes frames 2 through 5; 2..5 excludes frame 5. An omitted start preserves read progress, and an omitted end removes the cap. Raising the cap makes unread cached frames available again.

Source

pub fn skip_to(&mut self, index: u64)

Advance the read cursor to index, skipping every frame below it.

Unlike Self::set_frames, this does not clamp past a requested frame the group never held. A Producer::start_at floor above index still surfaces as Error::Lagged.

Source

pub fn frame_count(&self) -> usize

The number of frames written so far (completed plus any in-flight), independent of how many this consumer has read. The final total once the group is finished.

Source

pub async fn next_frame(&mut self) -> Result<Option<Consumer>>

Return a consumer for the next frame for chunked reading.

Source

pub fn poll_next_frame( &mut self, waiter: &Waiter, ) -> Poll<Result<Option<Consumer>>>

Poll for the next frame, without blocking.

Returns None if the group is finished and the index is out of range, or the cursor passed the Self::set_frames cap.

Source

pub fn poll_read_frame( &mut self, waiter: &Waiter, ) -> Poll<Result<Option<Frame>>>

Read the next frame (timestamp and payload) all at once, without blocking.

Source

pub async fn read_frame(&mut self) -> Result<Option<Frame>>

Read the next frame (timestamp and payload) all at once.

Source

pub fn poll_read_frames<const N: usize>( &mut self, waiter: &Waiter, out: &mut Buffer<N>, ) -> Poll<Result<usize>>

Fill out with every frame that is ready, up to its capacity, without blocking.

This is a short read: it returns as soon as anything is ready rather than waiting for out to fill. A zero count means the group ended when the buffer has non-zero capacity.

Source

pub async fn read_frames<'a, const N: usize>( &mut self, out: &'a mut Buffer<N>, ) -> Result<&'a mut [Frame]>

Fill out with every frame that is ready, blocking until a frame arrives or the group ends. Returns the current batch, empty only at the end of the group.

Source

pub fn poll_finished(&mut self, waiter: &Waiter) -> Poll<Result<u64>>

Poll until the group terminates, returning this cursor’s next frame index.

Source

pub async fn finished(&mut self) -> Result<u64>

Block until the group terminates, returning this cursor’s next frame index.

This answers for the cursor, not the group: a reader that drained every frame gets the clean end even if the group was aborted afterwards to release its cache, while one that stopped short gets that abort. A prior Self::skip_to contributes to the index even though those frames were not read. Use Self::frame_count for the producer’s total.

Trait Implementations§

Source§

impl Clone for Consumer

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Deref for Consumer

Source§

type Target = Info

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSend for T
where T: Send + ?Sized,

Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSync for T
where T: Sync,

Source§

impl<T> MaybeSync for T
where T: Sync,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more