pub struct Ordered { /* private fields */ }Expand description
A Subscriber that reads groups in key order.
Created by Subscriber::ordered, which consumes the subscriber, so a track is read
one way or the other and never both. Every group it returns has a higher key
than the last, so a late arrival (network reordering, or a gap the cache filled after
the fact) is skipped, or reported as a gap, rather than delivered out of turn.
§Age and skipping
A live join’s max applies as this cursor reads, exactly as it does on the
arrival cursor: a group is skipped once its reach, where its immediate successor
begins, is that far behind the newest frame on the track. Nothing weaker convicts it,
because the reach is the only proof that every frame it could still hold is past the
budget: a group’s own timestamps say where it starts presenting, not where it stops,
and an unstamped successor leaves it unbounded and therefore kept. A backlog inside
the budget is still delivered whole, as a burst in order, which is what a decoder
reading a gap-free key needs.
The same budget follows a group already handed out: once newer content pulls that far
ahead, a read still waiting on it ends with Error::Old and the cursor moves on.
§Gaps
A missing group is waited for only while the track still owes it: on a copy a
subscription feeds, a group that may still land, reordered behind its successor, is
read first, until the same budget gives up on it. Without a budget (None, which a
history or VOD read uses) it waits until the hole resolves. A group the track knows will never land costs nothing:
one the publisher dropped, one that arrived and was since evicted or aborted, or one
below where the feed starts. A locally produced track owes
nothing, so there the cursor seeks to the lowest cached group in range.
An unlimited or long budget only avoids blocking where the feed signals its gaps:
moq-lite, whose publisher sends SUBSCRIBE_DROP for every group it won’t deliver, or an
ordered moq-transport FETCH. A moq-transport SUBSCRIBE signals no gaps, so there a group
lost in transit can hold the ordered reader at its hole until the track ends.
A group this reader gives up on is not lost silently: Self::poll_next_item returns it as an
Item::Gap, so a reader that paces on what was sent counts the loss instead of
waiting for a group that will never come. That is every group the publisher or a relay
dropped, the transport evicted, the budget aged out, a fetch could not find, or that
landed after the read passed its key (reported as Old). A gap carries the keys it
spans and is returned once, after any group the read still owes below it and before
the next group above it, or when the track ends. Keys the publisher declared skipped
(see Producer::skip_groups) were never groups, so they are no gap;
Self::is_skipped answers for them.
The budget is updatable mid-stream through Self::control. Duration::ZERO (the
default) keeps only what nothing newer has superseded, so a consumer that stalls and
resumes rejoins the live edge instead of replaying at 1x.
Implementations§
Source§impl Ordered
impl Ordered
Sourcepub fn broadcast(&self) -> &Info
pub fn broadcast(&self) -> &Info
The broadcast this track belongs to, as reached through the handle it came from.
Sourcepub fn poll_next_group(
&mut self,
waiter: &Waiter,
) -> Poll<Result<Option<Consumer>>>
pub fn poll_next_group( &mut self, waiter: &Waiter, ) -> Poll<Result<Option<Consumer>>>
The next group with a higher key than any previously returned, passing over any gap
Self::poll_next_item would report below it.
Returns Ok(Some(group)) when a group is available, and otherwise ends as
Self::poll_next_item does.
Sourcepub async fn next_group(&mut self) -> Result<Option<Consumer>>
pub async fn next_group(&mut self) -> Result<Option<Consumer>>
The next group with a higher key than any previously returned, passing over any gap
Self::poll_next_item would report below it.
Returns Ok(Some(group)) when a group is available, and otherwise ends as
Self::poll_next_item does.
Awaits poll_next_group.
Sourcepub fn poll_next_item(&mut self, waiter: &Waiter) -> Poll<Result<Option<Item>>>
pub fn poll_next_item(&mut self, waiter: &Waiter) -> Poll<Result<Option<Item>>>
The next group with a higher key than any previously returned, or a gap this reader gave up on (see Gaps).
Honors the group range set by Subscriber::with_range before Subscriber::ordered:
a group past the cap stays in the producer’s cache and becomes eligible again if
the cap rises or is removed. Ranges that all end end the read once they are
accounted for, as for Subscriber::poll_recv_group. On a locally produced track that
includes a key below a group the producer created, which this read hands out first.
Later reads return Ok(None) immediately too; widening the ranges with
Self::update resumes reading above the end the read passed (or the cap, when that
was lower), so a group created below that end afterward is never handed out.
Returns Ok(Some(item)) when a group or gap is available, Ok(None) when the track is
finished (including an abort after its declared end settled, see Producer::abort)
or the ranges are read, or the error when the track has been aborted short of its end.
Every gap is returned before the end, even a clean one.
Sourcepub async fn next_item(&mut self) -> Result<Option<Item>>
pub async fn next_item(&mut self) -> Result<Option<Item>>
The next group with a higher key than any previously returned, or a gap this reader gave up on (see Gaps).
Honors the group range set by Subscriber::with_range before Subscriber::ordered:
a group past the cap stays in the producer’s cache and becomes eligible again if
the cap rises or is removed. Ranges that all end end the read once they are
accounted for, as for Subscriber::poll_recv_group. On a locally produced track that
includes a key below a group the producer created, which this read hands out first.
Later reads return Ok(None) immediately too; widening the ranges with
Self::update resumes reading above the end the read passed (or the cap, when that
was lower), so a group created below that end afterward is never handed out.
Returns Ok(Some(item)) when a group or gap is available, Ok(None) when the track is
finished (including an abort after its declared end settled, see Producer::abort)
or the ranges are read, or the error when the track has been aborted short of its end.
Every gap is returned before the end, even a clean one.
Awaits poll_next_item.
Sourcepub fn control(&self) -> Control
pub fn control(&self) -> Control
Create a handle for updating this subscriber’s delivery preferences without borrowing the read cursor.
Sourcepub fn refresh(&self) -> Refreshing ⓘ
pub fn refresh(&self) -> Refreshing ⓘ
Ask for a group newer than the newest held; see Subscriber::refresh.
Sourcepub fn subscription(&self) -> Subscription
pub fn subscription(&self) -> Subscription
This subscriber’s current preferences.
Sourcepub fn update(&mut self, subscription: Subscription) -> Result<()>
pub fn update(&mut self, subscription: Subscription) -> Result<()>
Replace this subscriber’s delivery preferences.
Returns Error::Closed if the track already ended.
Sourcepub fn poll_finished(&mut self, waiter: &Waiter) -> Poll<Result<Position>>
pub fn poll_finished(&mut self, waiter: &Waiter) -> Poll<Result<Position>>
The exclusive end position, once the track declares its end.
See Subscriber::poll_finished: this reports the declared end, not that every group
has arrived.
Sourcepub async fn finished(&mut self) -> Result<Position>
pub async fn finished(&mut self) -> Result<Position>
The exclusive end position, once the track declares its end.
See Subscriber::poll_finished: this reports the declared end, not that every group
has arrived.
Awaits poll_finished.
Sourcepub fn poll_largest(&mut self, waiter: &Waiter) -> Poll<Option<Position>>
pub fn poll_largest(&mut self, waiter: &Waiter) -> Poll<Option<Position>>
The largest location within Subscriber::with_range; see Subscriber::poll_largest.
Sourcepub async fn largest(&mut self) -> Option<Position>
pub async fn largest(&mut self) -> Option<Position>
The largest location within Subscriber::with_range; see Subscriber::poll_largest.
Awaits poll_largest.
Sourcepub fn is_skipped(&self, groups: Range<u64>) -> bool
pub fn is_skipped(&self, groups: Range<u64>) -> bool
Whether the publisher declared every start in groups skipped, never to be produced
(see Producer::skip_groups, which appending does between groups), so no group can
arrive there: true for an empty range. Unlike the gaps, this ignores the ranges. A copy
knows only the skips its wire forwarded.
What tells a reader that nothing lies between two groups, or before a track’s first.
It knows only the skips recorded so far, so false means “not known skipped”: a skip
still in flight reads false, as does one a local producer’s cache expired below its
edge. A reader that asks once treats such a group as one with something before it.