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 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 written on the peer’s stream).

The state is named for the requester’s view; for a responder 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 (REQUEST_ERROR written on the peer’s stream).

Source

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

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

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 (REQUEST_ERROR received).

Source

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

Pending | Receiving | Unanswered -> Done, Done -> Done (this fetch’s request stream was cancelled).

This draft carries no FETCH_CANCEL message. Section 3.3.3: “Once a request stream has been opened, the request MAY be cancelled by either endpoint.”

Idle is refused, on the other half of the same sentence: nothing has been written, so there is no stream to terminate. Done stays Done — nothing finishes a request stream’s send half on the ordinary path, so a caller that walks away from a request that has already ended still resets the stream, and that reset is an ordinary end rather than a fault.

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 10.13: a relay whose upstream FETCH failed “sends a REQUEST_ERROR and can reset the unidirectional stream”, and may “wait until the cached objects have been delivered before resetting the stream”, so that close arrives after the error ended the fetch. This draft has no FETCH_CANCEL message; Section 3.3.3 cancels a request by terminating the directions of its stream, which reaches this machine the same way.

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.

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