Skip to main content

FetchStateMachine

Struct FetchStateMachine 

Source
pub struct FetchStateMachine {
    state: FetchState,
}
Expand description

Pure state machine for a MoQT fetch request. Transitions: Idle → Pending → Receiving → Done when the answer comes first, and Idle → Pending → Unanswered → Done when the response stream ends first.

Fields§

§state: FetchState

Implementations§

Source§

impl FetchStateMachine

Source

pub fn new() -> Self

Creates a new state machine in the FetchState::Idle state.

Source

pub fn state(&self) -> FetchState

Returns the current state of the fetch request.

Source

pub fn on_fetch_sent(&mut self) -> Result<(), FetchError>

Idle → Pending (FETCH sent).

Source

pub fn on_fetch_ok(&mut self) -> Result<(), FetchError>

Pending → Receiving, Unanswered → Done (FETCH_OK received).

From Unanswered the objects have already been delivered, so the FETCH_OK describing them is the last thing the fetch was waiting for.

Source

pub fn on_fetch_error(&mut self) -> Result<(), FetchError>

Pending | Unanswered → Done (FETCH_ERROR received).

Source

pub fn on_fetch_cancel(&mut self) -> Result<(), FetchError>

Pending | Receiving | Unanswered → Done (FETCH_CANCEL sent).

Source

pub fn on_stream_fin(&mut self) -> Result<(), FetchError>

Receiving → Done, Pending → Unanswered (stream FIN received).

A fetch that has already ended ignores the close of its response stream, whichever of QUIC’s two endings it is. Section 8.15: the publisher of a cancelled fetch “SHOULD close the unidirectional stream as soon as possible”, and the cancel is what ended the fetch, so that close arrives afterwards.

Source

pub fn on_stream_reset(&mut self) -> Result<(), FetchError>

Receiving → Done, Pending → Unanswered (stream RESET received).

The same tolerance of a late close as FetchStateMachine::on_stream_fin, for the same reason.

Source§

impl FetchStateMachine

The same transitions, named for the end that serves the fetch.

A fetch this endpoint answers passes through the states in the same order as one it makes, with every message going the other way: the FETCH arrives instead of leaving, the answer leaves instead of arriving. Sharing the transitions and not the names is what lets a refusal say which event was refused, rather than naming the mirror image of it.

Source

pub fn on_fetch_received(&mut self) -> Result<(), FetchError>

Idle -> Pending (FETCH received from the peer).

Source

pub fn on_fetch_ok_sent(&mut self) -> Result<(), FetchError>

Pending -> Receiving, Unanswered -> Done (FETCH_OK sent).

The state is named for the requester’s view; for the end answering, the same node means the objects are being served rather than received. It is the same node in the graph, with the same edges, so it keeps its name.

Source

pub fn on_fetch_error_sent(&mut self) -> Result<(), FetchError>

Pending | Unanswered -> Done (FETCH_ERROR sent).

Source

pub fn on_fetch_cancel_received(&mut self) -> Result<(), FetchError>

Pending | Receiving | Unanswered -> Done (FETCH_CANCEL received).

Source

pub fn on_stream_fin_sent(&mut self) -> Result<(), FetchError>

Receiving -> Done, Pending -> Unanswered (this endpoint finished the fetch data stream).

Trait Implementations§

Source§

impl Default for FetchStateMachine

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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.

§

impl<T> Instrument for T

§

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

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

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, 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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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