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: FetchStateImplementations§
Source§impl FetchStateMachine
impl FetchStateMachine
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new state machine in the FetchState::Idle state.
Sourcepub fn state(&self) -> FetchState
pub fn state(&self) -> FetchState
Returns the current state of the fetch request.
Sourcepub fn on_fetch_sent(&mut self) -> Result<(), FetchError>
pub fn on_fetch_sent(&mut self) -> Result<(), FetchError>
Idle → Pending (FETCH sent).
Sourcepub fn on_fetch_ok(&mut self) -> Result<(), FetchError>
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.
Sourcepub fn on_fetch_error(&mut self) -> Result<(), FetchError>
pub fn on_fetch_error(&mut self) -> Result<(), FetchError>
Pending | Unanswered → Done (FETCH_ERROR received).
Sourcepub fn on_fetch_cancel(&mut self) -> Result<(), FetchError>
pub fn on_fetch_cancel(&mut self) -> Result<(), FetchError>
Pending | Receiving | Unanswered → Done (FETCH_CANCEL sent).
Sourcepub fn on_stream_fin(&mut self) -> Result<(), FetchError>
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 7.8: 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.
Sourcepub fn on_stream_reset(&mut self) -> Result<(), FetchError>
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.
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.
Sourcepub fn on_fetch_received(&mut self) -> Result<(), FetchError>
pub fn on_fetch_received(&mut self) -> Result<(), FetchError>
Idle -> Pending (FETCH received from the peer).
Sourcepub fn on_fetch_ok_sent(&mut self) -> Result<(), FetchError>
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.
Sourcepub fn on_fetch_error_sent(&mut self) -> Result<(), FetchError>
pub fn on_fetch_error_sent(&mut self) -> Result<(), FetchError>
Pending | Unanswered -> Done (FETCH_ERROR sent).
Sourcepub fn on_fetch_cancel_received(&mut self) -> Result<(), FetchError>
pub fn on_fetch_cancel_received(&mut self) -> Result<(), FetchError>
Pending | Receiving | Unanswered -> Done (FETCH_CANCEL received).
Sourcepub fn on_stream_fin_sent(&mut self) -> Result<(), FetchError>
pub fn on_stream_fin_sent(&mut self) -> Result<(), FetchError>
Receiving -> Done, Pending -> Unanswered (this endpoint finished the fetch data stream).