pub struct State {
inner: Inner,
}
Expand description
Represents the state of an H2 stream
+--------+
send PP | | recv PP
,--------| idle |--------.
/ | | \
v +--------+ v
+----------+ | +----------+
| | | send H / | |
,------| reserved | | recv H | reserved |------.
| | (local) | | | (remote) | |
| +----------+ v +----------+ |
| | +--------+ | |
| | recv ES | | send ES | |
| send H | ,-------| open |-------. | recv H |
| | / | | \ | |
| v v +--------+ v v |
| +----------+ | +----------+ |
| | half | | | half | |
| | closed | | send R / | closed | |
| | (remote) | | recv R | (local) | |
| +----------+ | +----------+ |
| | | | |
| | send ES / | recv ES / | |
| | send R / v send R / | |
| | recv R +--------+ recv R | |
| send R / `----------->| |<-----------' send R / |
| recv R | closed | recv R |
`----------------------->| |<----------------------'
+--------+
send: endpoint sends this frame
recv: endpoint receives this frame
H: HEADERS frame (with implied CONTINUATIONs)
PP: PUSH_PROMISE frame (with implied CONTINUATIONs)
ES: END_STREAM flag
R: RST_STREAM frame
Fields§
§inner: Inner
Implementations§
source§impl State
impl State
sourcepub fn send_open(&mut self, eos: bool) -> Result<(), UserError>
pub fn send_open(&mut self, eos: bool) -> Result<(), UserError>
Opens the send-half of a stream if it is not already open.
sourcepub fn recv_open(&mut self, frame: &Headers) -> Result<bool, Error>
pub fn recv_open(&mut self, frame: &Headers) -> Result<bool, Error>
Opens the receive-half of the stream when a HEADERS frame is received.
Returns true if this transitions the state to Open.
sourcepub fn reserve_remote(&mut self) -> Result<(), Error>
pub fn reserve_remote(&mut self) -> Result<(), Error>
Transition from Idle -> ReservedRemote
sourcepub fn reserve_local(&mut self) -> Result<(), UserError>
pub fn reserve_local(&mut self) -> Result<(), UserError>
Transition from Idle -> ReservedLocal
sourcepub fn recv_close(&mut self) -> Result<(), Error>
pub fn recv_close(&mut self) -> Result<(), Error>
Indicates that the remote side will not send more data to the local.
sourcepub fn recv_reset(&mut self, frame: Reset, queued: bool)
pub fn recv_reset(&mut self, frame: Reset, queued: bool)
The remote explicitly sent a RST_STREAM.
§Arguments
frame
: the received RST_STREAM frame.queued
: true if this stream has frames in the pending send queue.
sourcepub fn handle_error(&mut self, err: &Error)
pub fn handle_error(&mut self, err: &Error)
Handle a connection-level error.
pub fn recv_eof(&mut self)
sourcepub fn send_close(&mut self)
pub fn send_close(&mut self)
Indicates that the local side will not send more data to the local.
sourcepub fn set_reset(
&mut self,
stream_id: StreamId,
reason: Reason,
initiator: Initiator,
)
pub fn set_reset( &mut self, stream_id: StreamId, reason: Reason, initiator: Initiator, )
Set the stream state to reset locally.
sourcepub fn set_scheduled_reset(&mut self, reason: Reason)
pub fn set_scheduled_reset(&mut self, reason: Reason)
Set the stream state to a scheduled reset.
pub fn get_scheduled_reset(&self) -> Option<Reason>
pub fn is_scheduled_reset(&self) -> bool
pub fn is_local_error(&self) -> bool
pub fn is_remote_reset(&self) -> bool
pub fn is_send_streaming(&self) -> bool
sourcepub fn is_recv_headers(&self) -> bool
pub fn is_recv_headers(&self) -> bool
Returns true when the stream is in a state to receive headers
pub fn is_recv_streaming(&self) -> bool
pub fn is_closed(&self) -> bool
pub fn is_recv_closed(&self) -> bool
pub fn is_send_closed(&self) -> bool
pub fn is_idle(&self) -> bool
pub fn ensure_recv_open(&self) -> Result<bool, Error>
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for State
impl RefUnwindSafe for State
impl Send for State
impl Sync for State
impl Unpin for State
impl UnwindSafe for State
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)