Struct rustls::ClientSession[][src]

pub struct ClientSession { /* fields omitted */ }

This represents a single TLS client session.

Implementations

impl ClientSession[src]

pub fn new(
    config: &Arc<ClientConfig>,
    hostname: DNSNameRef<'_>
) -> ClientSession

Notable traits for ClientSession

impl Read for ClientSessionimpl Write for ClientSession
[src]

Make a new ClientSession. config controls how we behave in the TLS protocol, hostname is the hostname of who we want to talk to.

pub fn early_data(&mut self) -> Option<WriteEarlyData<'_>>[src]

Returns an io::Write implementor you can write bytes to to send TLS1.3 early data (a.k.a. “0-RTT data”) to the server.

This returns None in many circumstances when the capability to send early data is not available, including but not limited to:

  • The server hasn’t been talked to previously.
  • The server does not support resumption.
  • The server does not support early data.
  • The resumption data for the server has expired.

The server specifies a maximum amount of early data. You can learn this limit through the returned object, and writes through it will process only this many bytes.

The server can choose not to accept any sent early data – in this case the data is lost but the connection continues. You can tell this happened using is_early_data_accepted.

pub fn is_early_data_accepted(&self) -> bool[src]

Returns True if the server signalled it will process early data.

If you sent early data and this returns false at the end of the handshake then the server will not process the data. This is not an error, but you may wish to resend the data.

Trait Implementations

impl Debug for ClientSession[src]

impl Read for ClientSession[src]

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

Obtain plaintext data received from the peer over this TLS connection.

If the peer closes the TLS session cleanly, this fails with an error of kind ErrorKind::ConnectionAborted once all the pending data has been read. No further data can be received on that connection, so the underlying TCP connection should closed too.

Note that support close notify varies in peer TLS libraries: many do not support it and uncleanly close the TCP connection (this might be vulnerable to truncation attacks depending on the application protocol). This means applications using rustls must both handle ErrorKind::ConnectionAborted from this function, and unexpected closure of the underlying TCP connection.

impl Session for ClientSession[src]

fn write_tls(&mut self, wr: &mut dyn Write) -> Result<usize>[src]

Writes TLS messages to wr.

impl Write for ClientSession[src]

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

Send the plaintext buf to the peer, encrypting and authenticating it. Once this function succeeds you should call write_tls which will output the corresponding TLS records.

This function buffers plaintext sent before the TLS handshake completes, and sends it as soon as it can. This buffer is of unlimited size so writing much data before it can be sent will cause excess memory usage.

Auto Trait Implementations

impl !RefUnwindSafe for ClientSession

impl Send for ClientSession

impl Sync for ClientSession

impl Unpin for ClientSession

impl !UnwindSafe for ClientSession

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.