[][src]Trait solicit::http::session::SessionState

pub trait SessionState {
    type Stream: Stream;
    fn insert_outgoing(&mut self, stream: Self::Stream) -> StreamId;
fn insert_incoming(
        &mut self,
        id: StreamId,
        stream: Self::Stream
    ) -> Result<(), ()>;
fn get_stream_ref(&self, stream_id: StreamId) -> Option<&Self::Stream>;
fn get_stream_mut(
        &mut self,
        stream_id: StreamId
    ) -> Option<&mut Self::Stream>;
fn remove_stream(&mut self, stream_id: StreamId) -> Option<Self::Stream>;
fn iter(&mut self) -> StreamIter<Self::Stream>;
fn len(&self) -> usize; fn get_closed(&mut self) -> Vec<Self::Stream> { ... } }

A trait defining a set of methods for accessing and influencing an HTTP/2 session's state.

This trait is tightly coupled to a Stream-based session layer implementation. Particular implementations are additionally tightly coupled to one particular Stream implementation.

Note

Clients built on top of the raw HttpConnection + Session can still exist without using this trait; however, it is included for convenience, as most session implementations will want to keep track of similar things in the session's state.

Associated Types

type Stream: Stream

The type of the Stream that the SessionState manages.

Loading content...

Required methods

fn insert_outgoing(&mut self, stream: Self::Stream) -> StreamId

Inserts the given Stream into the session's state, starting to track it. The SessionState should assign it the next available outgoing stream ID.

fn insert_incoming(
    &mut self,
    id: StreamId,
    stream: Self::Stream
) -> Result<(), ()>

Inserts the given Stream into the session's state, considering it an incoming stream. TODO(mlalic): Allow the exact error to propagate out.

fn get_stream_ref(&self, stream_id: StreamId) -> Option<&Self::Stream>

Returns a reference to a Stream with the given StreamId, if it is found in the current session.

fn get_stream_mut(&mut self, stream_id: StreamId) -> Option<&mut Self::Stream>

Returns a mutable reference to a Stream with the given StreamId, if it is found in the current session.

fn remove_stream(&mut self, stream_id: StreamId) -> Option<Self::Stream>

Removes the stream with the given StreamId from the session. If the stream was found in the session, it is returned in the result.

fn iter(&mut self) -> StreamIter<Self::Stream>

Returns an iterator over the streams currently found in the session.

fn len(&self) -> usize

The number of streams tracked by this state object

Loading content...

Provided methods

fn get_closed(&mut self) -> Vec<Self::Stream>

Returns all streams that are closed and tracked by the session state.

The streams are moved out of the session state.

The default implementations relies on the iter implementation to find the closed streams first and then calls remove_stream on all of them.

Loading content...

Implementors

impl<T, S> SessionState for DefaultSessionState<T, S> where
    S: Stream
[src]

type Stream = S

fn len(&self) -> usize[src]

Number of currently active streams

Loading content...