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

pub trait Stream {
    fn new_data_chunk(&mut self, data: &[u8]);
fn set_headers<'n, 'v>(&mut self, headers: Vec<Header<'n, 'v>>);
fn set_state(&mut self, state: StreamState);
fn get_data_chunk(
        &mut self,
        buf: &mut [u8]
    ) -> Result<StreamDataChunk, StreamDataError>;
fn state(&self) -> StreamState; fn on_rst_stream(&mut self, _error_code: ErrorCode) { ... }
fn close(&mut self) { ... }
fn close_local(&mut self) { ... }
fn close_remote(&mut self) { ... }
fn is_closed(&self) -> bool { ... }
fn is_closed_local(&self) -> bool { ... }
fn is_closed_remote(&self) -> bool { ... } }

A trait representing a single HTTP/2 stream. An HTTP/2 connection multiplexes a number of streams.

The trait defines which operations need to be implemented by a type that should be usable as an HTTP/2 stream. By implementing this trait, clients can implement only stream-level logic, such as how the received data should be handled, or which data should be sent to the peer, without having to worry about the lower-level details of session and connection management (e.g. handling raw frames or tracking stream status).

Required methods

fn new_data_chunk(&mut self, data: &[u8])

Handle a new data chunk that has arrived for the stream.

fn set_headers<'n, 'v>(&mut self, headers: Vec<Header<'n, 'v>>)

Set headers for a stream. A stream is only allowed to have one set of headers.

fn set_state(&mut self, state: StreamState)

Sets the stream state to the newly provided state.

fn get_data_chunk(
    &mut self,
    buf: &mut [u8]
) -> Result<StreamDataChunk, StreamDataError>

Places the next data chunk that should be written onto the stream into the given buffer.

Returns

The returned variant of the StreamDataChunk enum can indicate that the returned chunk is the last one that the stream can write (the StreamDataChunk::Last variant).

It can also indicate that the stream currently does not have any data that could be written, but it isn't closed yet, implying that at a later time some data might become available for writing (the StreamDataChunk::Unavailable variant).

The StreamDataChunk::Chunk indicates that the chunk of the given length has been placed into the buffer and that more data might follow on the stream.

fn state(&self) -> StreamState

Returns the current state of the stream.

Loading content...

Provided methods

fn on_rst_stream(&mut self, _error_code: ErrorCode)

Invoked when the session detects that the peer has reset the stream (i.e. sent a RST_STREAM frame for this stream).

The default implementation simply closes the stream, discarding the provided error_code. Concrete Stream implementations can override this.

fn close(&mut self)

Transitions the stream state to closed. After this, the stream is considered to be closed for any further reads or writes.

fn close_local(&mut self)

Updates the Stream status to indicate that it is closed locally.

If the stream is closed on the remote end, then it is fully closed after this call.

fn close_remote(&mut self)

Updates the Stream status to indicate that it is closed on the remote peer's side.

If the stream is also locally closed, then it is fully closed after this call.

fn is_closed(&self) -> bool

Returns whether the stream is closed.

A stream is considered to be closed iff its state is set to Closed.

fn is_closed_local(&self) -> bool

Returns whether the stream is closed locally.

fn is_closed_remote(&self) -> bool

Returns whether the remote peer has closed the stream. This includes a fully closed stream.

Loading content...

Implementors

impl Stream for DefaultStream[src]

Loading content...