Struct h2::proto::streams::recv::Recv

source ·
pub(super) struct Recv {
Show 14 fields init_window_sz: u32, flow: FlowControl, in_flight_data: u32, next_stream_id: Result<StreamId, StreamIdOverflow>, last_processed_id: StreamId, max_stream_id: StreamId, pending_window_updates: Queue<NextWindowUpdate>, pending_accept: Queue<NextAccept>, pending_reset_expired: Queue<NextResetExpire>, reset_duration: Duration, buffer: Buffer<Event>, refused: Option<StreamId>, is_push_enabled: bool, is_extended_connect_protocol_enabled: bool,
}

Fields§

§init_window_sz: u32

Initial window size of remote initiated streams

§flow: FlowControl

Connection level flow control governing received data

§in_flight_data: u32

Amount of connection window capacity currently used by outstanding streams.

§next_stream_id: Result<StreamId, StreamIdOverflow>

The lowest stream ID that is still idle

§last_processed_id: StreamId

The stream ID of the last processed stream

§max_stream_id: StreamId

Any streams with a higher ID are ignored.

This starts as MAX, but is lowered when a GOAWAY is received.

After sending a GOAWAY frame, the sender can discard frames for streams initiated by the receiver with identifiers higher than the identified last stream.

§pending_window_updates: Queue<NextWindowUpdate>

Streams that have pending window updates

§pending_accept: Queue<NextAccept>

New streams to be accepted

§pending_reset_expired: Queue<NextResetExpire>

Locally reset streams that should be reaped when they expire

§reset_duration: Duration

How long locally reset streams should ignore received frames

§buffer: Buffer<Event>

Holds frames that are waiting to be read

§refused: Option<StreamId>

Refused StreamId, this represents a frame that must be sent out.

§is_push_enabled: bool

If push promises are allowed to be received.

§is_extended_connect_protocol_enabled: bool

If extended connect protocol is enabled.

Implementations§

source§

impl Recv

source

pub fn new(peer: Dyn, config: &Config) -> Self

source

pub fn init_window_sz(&self) -> u32

Returns the initial receive window size

source

pub fn last_processed_id(&self) -> StreamId

Returns the ID of the last processed stream

source

pub fn open( &mut self, id: StreamId, mode: Open, counts: &mut Counts, ) -> Result<Option<StreamId>, Error>

Update state reflecting a new, remotely opened stream

Returns the stream state if successful. None if refused

source

pub fn recv_headers( &mut self, frame: Headers, stream: &mut Ptr<'_>, counts: &mut Counts, ) -> Result<(), RecvHeaderBlockError<Option<Headers>>>

Transition the stream state based on receiving headers

The caller ensures that the frame represents headers and not trailers.

source

pub fn take_request(&mut self, stream: &mut Ptr<'_>) -> Request<()>

Called by the server to get the request

§Panics

Panics if stream.pending_recv has no Event::Headers queued.

source

pub fn poll_pushed( &mut self, cx: &Context<'_>, stream: &mut Ptr<'_>, ) -> Poll<Option<Result<(Request<()>, Key), Error>>>

Called by the client to get pushed response

source

pub fn poll_response( &mut self, cx: &Context<'_>, stream: &mut Ptr<'_>, ) -> Poll<Result<Response<()>, Error>>

Called by the client to get the response

source

pub fn recv_trailers( &mut self, frame: Headers, stream: &mut Ptr<'_>, ) -> Result<(), Error>

Transition the stream based on receiving trailers

source

pub fn release_connection_capacity( &mut self, capacity: u32, task: &mut Option<Waker>, )

Releases capacity of the connection

source

pub fn release_capacity( &mut self, capacity: u32, stream: &mut Ptr<'_>, task: &mut Option<Waker>, ) -> Result<(), UserError>

Releases capacity back to the connection & stream

source

pub fn release_closed_capacity( &mut self, stream: &mut Ptr<'_>, task: &mut Option<Waker>, )

Release any unclaimed capacity for a closed stream.

source

pub fn set_target_connection_window( &mut self, target: u32, task: &mut Option<Waker>, ) -> Result<(), Reason>

Set the “target” connection window size.

By default, all new connections start with 64kb of window size. As streams used and release capacity, we will send WINDOW_UPDATEs for the connection to bring it back up to the initial “target”.

Setting a target means that we will try to tell the peer about WINDOW_UPDATEs so the peer knows it has about target window to use for the whole connection.

The task is an optional parked task for the Connection that might be blocked on needing more window capacity.

source

pub(crate) fn apply_local_settings( &mut self, settings: &Settings, store: &mut Store, ) -> Result<(), Error>

source

pub fn is_end_stream(&self, stream: &Ptr<'_>) -> bool

source

pub fn recv_data( &mut self, frame: Data, stream: &mut Ptr<'_>, ) -> Result<(), Error>

source

pub fn ignore_data(&mut self, sz: u32) -> Result<(), Error>

source

pub fn consume_connection_window(&mut self, sz: u32) -> Result<(), Error>

source

pub fn recv_push_promise( &mut self, frame: PushPromise, stream: &mut Ptr<'_>, ) -> Result<(), Error>

source

pub fn ensure_not_idle(&self, id: StreamId) -> Result<(), Reason>

Ensures that id is not in the Idle state.

source

pub fn recv_reset( &mut self, frame: Reset, stream: &mut Stream, counts: &mut Counts, ) -> Result<(), Error>

Handle remote sending an explicit RST_STREAM.

source

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

Handle a connection-level error

source

pub fn go_away(&mut self, last_processed_id: StreamId)

source

pub fn recv_eof(&mut self, stream: &mut Stream)

source

pub(super) fn clear_recv_buffer(&mut self, stream: &mut Stream)

source

pub fn max_stream_id(&self) -> StreamId

Get the max ID of streams we can receive.

This gets lowered if we send a GOAWAY frame.

source

pub fn next_stream_id(&self) -> Result<StreamId, Error>

source

pub fn may_have_created_stream(&self, id: StreamId) -> bool

source

pub(super) fn maybe_reset_next_stream_id(&mut self, id: StreamId)

source

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

Returns true if the remote peer can reserve a stream with the given ID.

source

pub fn enqueue_reset_expiration( &mut self, stream: &mut Ptr<'_>, counts: &mut Counts, )

Add a locally reset stream to queue to be eventually reaped.

source

pub fn send_pending_refusal<T, B>( &mut self, cx: &mut Context<'_>, dst: &mut Codec<T, Prioritized<B>>, ) -> Poll<Result<()>>
where T: AsyncWrite + Unpin, B: Buf,

Send any pending refusals.

source

pub fn clear_expired_reset_streams( &mut self, store: &mut Store, counts: &mut Counts, )

source

pub fn clear_queues( &mut self, clear_pending_accept: bool, store: &mut Store, counts: &mut Counts, )

source

fn clear_stream_window_update_queue( &mut self, store: &mut Store, counts: &mut Counts, )

source

fn clear_all_reset_streams(&mut self, store: &mut Store, counts: &mut Counts)

Called on EOF

source

fn clear_all_pending_accept(&mut self, store: &mut Store, counts: &mut Counts)

source

pub fn poll_complete<T, B>( &mut self, cx: &mut Context<'_>, store: &mut Store, counts: &mut Counts, dst: &mut Codec<T, Prioritized<B>>, ) -> Poll<Result<()>>
where T: AsyncWrite + Unpin, B: Buf,

source

fn send_connection_window_update<T, B>( &mut self, cx: &mut Context<'_>, dst: &mut Codec<T, Prioritized<B>>, ) -> Poll<Result<()>>
where T: AsyncWrite + Unpin, B: Buf,

Send connection level window update

source

pub fn send_stream_window_updates<T, B>( &mut self, cx: &mut Context<'_>, store: &mut Store, counts: &mut Counts, dst: &mut Codec<T, Prioritized<B>>, ) -> Poll<Result<()>>
where T: AsyncWrite + Unpin, B: Buf,

Send stream level window update

source

pub fn next_incoming(&mut self, store: &mut Store) -> Option<Key>

source

pub fn poll_data( &mut self, cx: &Context<'_>, stream: &mut Stream, ) -> Poll<Option<Result<Bytes, Error>>>

source

pub fn poll_trailers( &mut self, cx: &Context<'_>, stream: &mut Stream, ) -> Poll<Option<Result<HeaderMap, Error>>>

source

fn schedule_recv<T>( &mut self, cx: &Context<'_>, stream: &mut Stream, ) -> Poll<Option<Result<T, Error>>>

Trait Implementations§

source§

impl Debug for Recv

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Recv

§

impl !RefUnwindSafe for Recv

§

impl Send for Recv

§

impl Sync for Recv

§

impl Unpin for Recv

§

impl !UnwindSafe for Recv

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.

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, 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