pub struct Consumer { /* private fields */ }Expand description
Consumes a binary value from a track, yielding the newest one.
Jumps to the newest group and reads the value out of it, so a late joiner starts at the current value rather than replaying superseded ones.
Implementations§
Source§impl Consumer
impl Consumer
Sourcepub fn new(track: Subscriber, config: Config) -> Self
pub fn new(track: Subscriber, config: Config) -> Self
Create a consumer reading from the given track subscriber.
Set Config::compression to match the producer that wrote the track.
Sourcepub async fn next(&mut self) -> Result<Option<Bytes>>
pub async fn next(&mut self) -> Result<Option<Bytes>>
Get the next value, or None once the track ends.
Sourcepub fn poll_next(&mut self, waiter: &Waiter) -> Poll<Result<Option<Bytes>>>
pub fn poll_next(&mut self, waiter: &Waiter) -> Poll<Result<Option<Bytes>>>
Poll for the next value, without blocking.
Jumps to the newest group and drains everything buffered in it, yielding only the last value: the earlier ones are already superseded, so a consumer that has fallen behind catches up to the head in a single step. A compressed group’s frames are still decoded in order, since they share one window; only the yield is skipped. Switching to a newer group discards the older one.
A group the transport can no longer serve is discarded the same way, not reported: on a snapshot track its content is superseded by definition, so the reader waits for the replacement. Only a failure of the track itself ends the stream.