Skip to main content

Consumer

Struct Consumer 

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

Consumes a JSON value from a track, reconstructing it from snapshots and deltas.

A Decoder that owns its track: it reads groups, routes each frame by its position, and yields each reconstructed state and its frame timestamp, or skips to the newest with latest. When something else already owns the track, use the Decoder directly.

A snapshot is superseded the moment a newer one exists, so by default the consumer subscribes itself at Start::LATEST and keeps that subscription to itself: a group is skipped once a newer one arrives, and a lower group the subscription still owes never holds up a newer one. Config::delay keeps superseded groups for a reader that applies each snapshot at its timestamp.

Implementations§

Source§

impl<T: DeserializeOwned> Consumer<T>

Source

pub fn new(track: Consumer, config: Config) -> Self

Create a consumer reading from the given track.

Takes the track where the stream and window consumers take a subscriber: a superseded value is worthless unless the reader holds it, so the consumer owns its subscription and fixes its budget at Config::delay. Subscribes right away at Config::priority and Config::delay, with default preferences otherwise; no handle to that subscription leaves the consumer, so nothing can change its budget. A read waits until the subscription resolves, and fails if it cannot. A compressed track reads the same: moq-net inflates it.

Source

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

Wait for the consumer’s own subscription to resolve, returning the track’s info.

Fails with the subscription’s error, such as a refused or missing track, on that same subscription a read would use: no second request, and no window between them.

Source

pub async fn info(&mut self) -> Result<Info>

Wait for the consumer’s own subscription to resolve, returning the track’s info.

Fails with the subscription’s error, such as a refused or missing track, on that same subscription a read would use: no second request, and no window between them.

Awaits poll_info.

Source

pub fn poll_next(&mut self, waiter: &Waiter) -> Poll<Result<Option<Timed<T>>>>

Get the next state and its exact frame timestamp, or None once the track ends.

Skips every group a newer one has superseded. Finish the current group’s buffered frames before taking the next. A group that fails, whatever with, resynchronizes from a later snapshot; only the track’s own error ends the reader.

Source

pub async fn next(&mut self) -> Result<Option<Timed<T>>>

Get the next state and its exact frame timestamp, or None once the track ends.

Skips every group a newer one has superseded. Finish the current group’s buffered frames before taking the next. A group that fails, whatever with, resynchronizes from a later snapshot; only the track’s own error ends the reader.

Awaits poll_next.

Source

pub fn poll_latest(&mut self, waiter: &Waiter) -> Poll<Result<Option<Timed<T>>>>

Get the newest state and its timestamp, discarding superseded groups and intermediate yields.

Frames inside the newest group are still decoded in order. What this skips is gone; a subsequent next resumes after it. On a scale-less track at is the group key.

Source

pub async fn latest(&mut self) -> Result<Option<Timed<T>>>

Get the newest state and its timestamp, discarding superseded groups and intermediate yields.

Frames inside the newest group are still decoded in order. What this skips is gone; a subsequent next resumes after it. On a scale-less track at is the group key.

Awaits poll_latest.

Auto Trait Implementations§

§

impl<T> !Freeze for Consumer<T>

§

impl<T> !RefUnwindSafe for Consumer<T>

§

impl<T> !Sync for Consumer<T>

§

impl<T> Send for Consumer<T>

§

impl<T> Unpin for Consumer<T>

§

impl<T> UnsafeUnpin for Consumer<T>

§

impl<T> UnwindSafe for Consumer<T>

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> 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<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