pub struct Consumer<T> { /* private fields */ }Expand description
Consumes a JSON value from a track, reconstructing it from snapshots and deltas.
Implementations§
Source§impl<T: DeserializeOwned> Consumer<T>
impl<T: DeserializeOwned> Consumer<T>
Sourcepub fn new(track: TrackConsumer, config: ConsumerConfig) -> Self
pub fn new(track: TrackConsumer, config: ConsumerConfig) -> Self
Create a consumer reading from the given track subscriber.
Set ConsumerConfig::compression to read a track written by a producer with
ProducerConfig::compression on.
Sourcepub async fn next(&mut self) -> Result<Option<T>>where
T: Unpin,
pub async fn next(&mut self) -> Result<Option<T>>where
T: Unpin,
Get the next reconstructed value, or None once the track ends.
Sourcepub fn poll_next(&mut self, waiter: &Waiter) -> Poll<Result<Option<T>>>
pub fn poll_next(&mut self, waiter: &Waiter) -> Poll<Result<Option<T>>>
Poll for the next reconstructed value, without blocking.
Jumps to the newest group, reads its snapshot, and applies deltas in order. All frames already buffered in the group are applied in one poll but only the resulting latest value is yielded: the intermediate reconstructions are stale, so a late joiner (or any consumer that has fallen behind) catches up to the head in a single step instead of replaying every superseded state. Frames must still be decoded in order (the DEFLATE window and merge patches are sequential); only the per-frame deserialize and yield are skipped. Switching to a newer group discards the older one.