Skip to main content

Session

Struct Session 

Source
pub struct Session { /* private fields */ }
Expand description

A single HTTP(S) connection in progress.

Implementations§

Source§

impl Session

Source

pub fn plain(cfg: SessionConfig) -> Session

Create a plaintext (HTTP/1.x) session.

Source

pub fn tls(cfg: SessionConfig, stream: TlsStream) -> Session

Create a TLS (HTTPS) session wrapping an accepted TlsStream. The protocol (HTTP/1.1 or HTTP/2) is chosen once ALPN is known.

Source

pub fn received(&mut self, wire_in: &[u8]) -> Result<()>

Feed bytes received from the socket: decrypt, (lazily) select the protocol, parse requests, run the handler, and queue responses.

Source

pub fn to_send(&mut self) -> Result<Vec<u8>>

Produce the bytes to write to the socket: TLS handshake records and/or (encrypted) response data. May be empty.

Source

pub fn has_output(&self) -> bool

Whether the engine still has output to produce — queued bytes or a response body (e.g. a file) being streamed in chunks. Drivers must keep calling to_send while this is true before waiting for the next read or closing, so a body is flushed in full.

Source

pub fn wants_close(&self) -> bool

Whether the connection should be closed once pending output is written.

Source

pub fn handshaking(&self) -> bool

Whether the session is still completing the TLS handshake.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.