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 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 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.
Sourcepub fn on_fetch_error_sent(&mut self) -> Result<(), FetchError>
pub fn on_fetch_error_sent(&mut self) -> Result<(), FetchError>
Pending | Unanswered -> Done (REQUEST_ERROR written on the peer’s stream).
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).
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 (REQUEST_ERROR received).
Sourcepub fn on_request_cancelled(&mut self) -> Result<(), FetchError>
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.2: “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.
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 10.12.3: 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.2 cancels a request by terminating the directions of its stream, which reaches this machine the same way.
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.