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>
impl<T: DeserializeOwned> Consumer<T>
Sourcepub fn new(track: Consumer, config: Config) -> Self
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.
Sourcepub fn poll_info(&mut self, waiter: &Waiter) -> Poll<Result<Info>>
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.
Sourcepub async fn info(&mut self) -> Result<Info>
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.
Sourcepub fn poll_next(&mut self, waiter: &Waiter) -> Poll<Result<Option<Timed<T>>>>
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.
Sourcepub async fn next(&mut self) -> Result<Option<Timed<T>>>
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.
Sourcepub fn poll_latest(&mut self, waiter: &Waiter) -> Poll<Result<Option<Timed<T>>>>
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.
Sourcepub async fn latest(&mut self) -> Result<Option<Timed<T>>>
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.