Struct h2::proto::streams::state::State

source ·
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

source

pub fn send_open(&mut self, eos: bool) -> Result<(), UserError>

Opens the send-half of a stream if it is not already open.

source

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.

source

pub fn reserve_remote(&mut self) -> Result<(), Error>

Transition from Idle -> ReservedRemote

source

pub fn reserve_local(&mut self) -> Result<(), UserError>

Transition from Idle -> ReservedLocal

source

pub fn recv_close(&mut self) -> Result<(), Error>

Indicates that the remote side will not send more data to the local.

source

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.
source

pub fn handle_error(&mut self, err: &Error)

Handle a connection-level error.

source

pub fn recv_eof(&mut self)

source

pub fn send_close(&mut self)

Indicates that the local side will not send more data to the local.

source

pub fn set_reset( &mut self, stream_id: StreamId, reason: Reason, initiator: Initiator, )

Set the stream state to reset locally.

source

pub fn set_scheduled_reset(&mut self, reason: Reason)

Set the stream state to a scheduled reset.

source

pub fn get_scheduled_reset(&self) -> Option<Reason>

source

pub fn is_scheduled_reset(&self) -> bool

source

pub fn is_local_error(&self) -> bool

source

pub fn is_remote_reset(&self) -> bool

source

pub fn is_reset(&self) -> bool

Returns true if the stream is already reset.

source

pub fn is_send_streaming(&self) -> bool

source

pub fn is_recv_headers(&self) -> bool

Returns true when the stream is in a state to receive headers

source

pub fn is_recv_streaming(&self) -> bool

source

pub fn is_closed(&self) -> bool

source

pub fn is_recv_closed(&self) -> bool

source

pub fn is_send_closed(&self) -> bool

source

pub fn is_idle(&self) -> bool

source

pub fn ensure_recv_open(&self) -> Result<bool, Error>

source

pub(super) fn ensure_reason( &self, mode: PollReset, ) -> Result<Option<Reason>, Error>

Returns a reason if the stream has been reset.

Trait Implementations§

source§

impl Clone for State

source§

fn clone(&self) -> State

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for State

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for State

source§

fn default() -> State

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

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> 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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

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

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

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> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> WithSubscriber for T

source§

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
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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