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
impl Consumer
Sourcepub fn timescale(&self) -> Option<Timescale>
pub fn timescale(&self) -> Option<Timescale>
The parent track’s timescale, or None when it declared no timeline.
Sourcepub fn created(&self) -> Instant
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.
Sourcepub fn index(&self) -> u64
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.
Sourcepub fn with_range(self, frames: impl RangeBounds<u64>) -> Self
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.
Sourcepub fn skip_to(&mut self, index: u64)
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.
Sourcepub fn frame_count(&self) -> usize
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.
Sourcepub fn end(&self) -> Option<u64>
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.
Sourcepub fn poll_next_frame(
&mut self,
waiter: &Waiter,
) -> Poll<Result<Option<Consumer>>>
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.
Sourcepub async fn next_frame(&mut self) -> Result<Option<Consumer>>
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.
Sourcepub fn poll_read_frame(
&mut self,
waiter: &Waiter,
) -> Poll<Result<Option<Frame>>>
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.
Sourcepub async fn read_frame(&mut self) -> Result<Option<Frame>>
pub async fn read_frame(&mut self) -> Result<Option<Frame>>
Read the next frame (timestamp and payload) all at once.
Sourcepub fn poll_finished(&mut self, waiter: &Waiter) -> Poll<Result<u64>>
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.
Sourcepub async fn finished(&mut self) -> Result<u64>
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.