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

pub trait Stream {
    fn new(stream_id: StreamId) -> Self;
fn new_data_chunk(&mut self, data: &[u8]);
fn set_headers(&mut self, headers: Vec<Header>);
fn set_state(&mut self, state: StreamState);
fn get_data_chunk(
        &mut self,
        buf: &mut [u8]
    ) -> Result<StreamDataChunk, StreamDataError>;
fn id(&self) -> StreamId;
fn state(&self) -> StreamState; 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

Create a new stream with the given ID

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

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

Sets the stream state to the newly provided state.

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.

Returns the ID of the stream.

Returns the current state of the stream.

Provided Methods

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

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.

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.

Returns whether the stream is closed.

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

Returns whether the stream is closed locally.

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

Implementors