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

pub trait SessionState {
    type Stream: Stream;
    fn insert_stream(&mut self, stream: Self::Stream);
    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 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.

Required Methods

fn insert_stream(&mut self, stream: Self::Stream)

Inserts the given Stream into the session's state, starting to track it.

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.

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.

Implementors