Skip to main content

Ordered

Struct Ordered 

Source
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

Source

pub fn info(&self) -> &Info

The track’s Info, resolved when the subscription was established.

Source

pub fn name(&self) -> &str

The track’s name, unique within its broadcast.

Source

pub fn broadcast(&self) -> &Info

The broadcast this track belongs to, as reached through the handle it came from.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn control(&self) -> Control

Create a handle for updating this subscriber’s delivery preferences without borrowing the read cursor.

Source

pub fn refresh(&self) -> Refreshing ⓘ

Ask for a group newer than the newest held; see Subscriber::refresh.

Source

pub fn subscription(&self) -> Subscription

This subscriber’s current preferences.

Source

pub fn update(&mut self, subscription: Subscription) -> Result<()>

Replace this subscriber’s delivery preferences.

Returns Error::Closed if the track already ended.

Source

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.

Source

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.

Source

pub fn poll_largest(&mut self, waiter: &Waiter) -> Poll<Option<Position>>

The largest location within Subscriber::with_range; see Subscriber::poll_largest.

Source

pub async fn largest(&mut self) -> Option<Position>

The largest location within Subscriber::with_range; see Subscriber::poll_largest.

Awaits poll_largest.

Source

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.

Source

pub fn is_clone(&self, other: &Self) -> bool

Whether other reads the same underlying track state.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more