Trait solicit::http::transport::TransportStream [] [src]

pub trait TransportStream: Read + Write + Sized {
    fn try_split(&self) -> Result<Self, Error>;
    fn close(&mut self) -> Result<(), Error>;

    fn read_exact(&mut self, buf: &mut [u8]) -> Result<()> { ... }
}

A trait that any struct that wants to provide the transport layer for HTTP/2 needs to implement.

It provides default implementations for some convenience methods, backed by the Read and Write implementations.

Required Methods

fn try_split(&self) -> Result<Self, Error>

Attempts to split the TransportStream instance into a new independently owned handle to the same underlying stream.

fn close(&mut self) -> Result<(), Error>

Attempts to shutdown both ends of the transport stream.

If successful, all handles to the stream created by the try_split operation will start receiving an error for any IO operations.

Provided Methods

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

A convenience method that performs as many read calls on the underlying Read implementation as it takes to fill the given buffer.

The implementation simply calls the read in a loop until the buffer is filled or an aparent end of file is reached, upon which an error is returned.

However, no particular care is taken to limit the number of loop iterations and it could theoretically be possible to end up reading a single byte at a time into a large buffer, taking a long time to return.

Any errors raised by the underlying Read implementations are propagated.

When an error is raised, the given buffer is only partially filled, but there is no way to know how many bytes were actually written to the underlying buffer, which means that, effectively, all read bytes are lost on any error.

Implementors