Skip to main content

Consumer

Struct Consumer 

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

Consume a group, frame-by-frame.

A read’s error belongs to this group alone, whatever it says: the track reads on, so a reader moves to the next group rather than matching the error. Only the track’s own reads report that the track ended.

Implementations§

Source§

impl Consumer

Source

pub fn timescale(&self) -> Option<Timescale>

The parent track’s timescale, or None when it declared no timeline.

Source

pub fn created(&self) -> Instant

When the group was created at this hop, before its first frame, on the ambient clock: when its header was received, or when it was fetched or created here.

Fixed for the consumer’s life, so a reader that pulls the group late still measures from when it landed, as frame::Frame::created does for each frame. A consumer resumed onto a replacement copy keeps the original group’s arrival.

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::with_range has clamped it, and advances by one per frame read.

Source

pub fn with_range(self, frames: impl RangeBounds<u64>) -> Self

Limit subsequent reads to these frame indices without rewinding read progress, returning self for chaining.

2..=5 includes frames 2 through 5; 2..5 excludes frame 5, and ..0 is the empty range. The start skips ahead, clamped up to the group’s first available frame: frames the group never held (see Producer::start_at) can’t be returned, so read Self::index back to learn where the cursor landed. A start below the cursor is ignored, since those frames may already have been handed out. The end is assigned: reads past it end cleanly (None), as if the group finished there, and an omitted end removes the cap. Raising the cap re-offers frames that are still cached.

Source

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

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

Unlike Self::with_range, this does not clamp past a requested frame the group never held. A Producer::start_at floor above index makes a read fetch the frames below it, from a front’s route or the track’s crate::track::Requests handlers, and surfaces as Error::Lagged when neither can serve them.

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 fn end(&self) -> Option<u64>

Where the group ends in its track’s timescale, once its producer finished it whole with Producer::finish_at, kept after its cache is released: None while it is open, when it was aborted unfinished, or when it finished without an end.

Source

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

The next frame, as a consumer for chunked reading.

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

Source

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

The next frame, as a consumer for chunked reading.

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

Awaits poll_next_frame.

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_finished(&mut self, waiter: &Waiter) -> Poll<Result<u64>>

This cursor’s next frame index once the group terminates, or this cursor reaches the end of its range.

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.

An error means the frames this cursor has yet to read are gone (evicted, cut, or failed upstream) and no route will continue them.

Source

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

This cursor’s next frame index once the group terminates, or this cursor reaches the end of its range.

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.

An error means the frames this cursor has yet to read are gone (evicted, cut, or failed upstream) and no route will continue them.

Awaits poll_finished.

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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