Session

Struct Session 

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

TLS session with RAII cleanup.

Wraps ove_tls_t and frees resources on drop.

Implementations§

Source§

impl Session

Source

pub fn new() -> Result<Self>

Create a new TLS session via heap allocation (only in heap mode).

Source

pub fn handshake(&self, sock: &TcpStream, cfg: &TlsConfig<'_>) -> Result<()>

Perform the TLS handshake over an established TCP connection.

After a successful handshake, use send and recv for encrypted I/O.

§Errors

Returns an error if the handshake fails (certificate mismatch, protocol error, etc.).

Source

pub fn send(&self, data: &[u8]) -> Result<usize>

Send data over the encrypted session.

Returns the number of bytes actually sent.

§Errors

Returns an error if the send fails.

Source

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

Receive data from the encrypted session.

Returns the number of bytes received into buf.

§Errors

Returns an error if the receive fails or the peer closed the connection.

Source

pub fn close(&self)

Shut down the TLS session (sends close_notify).

The underlying socket is NOT closed – the caller must close it separately.

Trait Implementations§

Source§

impl Debug for Session

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Session

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Session

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.