Struct embedded_tls::blocking::TlsConnection
source · pub struct TlsConnection<'a, Socket, CipherSuite>where
Socket: Read + Write + 'a,
CipherSuite: TlsCipherSuite + 'static,{ /* private fields */ }
Expand description
Type representing an async TLS connection. An instance of this type can be used to establish a TLS connection, write and read encrypted data over this connection, and closing to free up the underlying resources.
Implementations§
source§impl<'a, Socket, CipherSuite> TlsConnection<'a, Socket, CipherSuite>where
Socket: Read + Write + 'a,
CipherSuite: TlsCipherSuite + 'static,
impl<'a, Socket, CipherSuite> TlsConnection<'a, Socket, CipherSuite>where
Socket: Read + Write + 'a,
CipherSuite: TlsCipherSuite + 'static,
sourcepub fn new(delegate: Socket, record_buf: &'a mut [u8]) -> Self
pub fn new(delegate: Socket, record_buf: &'a mut [u8]) -> Self
Create a new TLS connection with the provided context and a I/O implementation
NOTE: The record buffer should be sized to fit an encrypted TLS record and the TLS handshake record. The maximum value of a TLS record is 16 kB, which should be a safe value to use.
sourcepub fn open<'m, RNG: CryptoRng + RngCore + 'm, Clock: TlsClock + 'static, const CERT_SIZE: usize>(
&mut self,
context: TlsContext<'m, CipherSuite, RNG>
) -> Result<(), TlsError>where
'a: 'm,
pub fn open<'m, RNG: CryptoRng + RngCore + 'm, Clock: TlsClock + 'static, const CERT_SIZE: usize>(
&mut self,
context: TlsContext<'m, CipherSuite, RNG>
) -> Result<(), TlsError>where
'a: 'm,
Open a TLS connection, performing the handshake with the configuration provided when creating the connection instance.
The handshake may support certificates up to CERT_SIZE.
Returns an error if the handshake does not proceed. If an error occurs, the connection instance must be recreated.
sourcepub fn write(&mut self, buf: &[u8]) -> Result<usize, TlsError>
pub fn write(&mut self, buf: &[u8]) -> Result<usize, TlsError>
Encrypt and send the provided slice over the connection. The connection must be opened before writing.
Returns the number of bytes written.
Trait Implementations§
source§impl<'a, Socket, CipherSuite> Io for TlsConnection<'a, Socket, CipherSuite>where
Socket: Read + Write + 'a,
CipherSuite: TlsCipherSuite + 'static,
impl<'a, Socket, CipherSuite> Io for TlsConnection<'a, Socket, CipherSuite>where
Socket: Read + Write + 'a,
CipherSuite: TlsCipherSuite + 'static,
source§impl<'a, Socket, CipherSuite> Read for TlsConnection<'a, Socket, CipherSuite>where
Socket: Read + Write + 'a,
CipherSuite: TlsCipherSuite + 'static,
impl<'a, Socket, CipherSuite> Read for TlsConnection<'a, Socket, CipherSuite>where
Socket: Read + Write + 'a,
CipherSuite: TlsCipherSuite + 'static,
source§fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
source§fn read_exact(
&mut self,
buf: &mut [u8]
) -> Result<(), ReadExactError<Self::Error>>
fn read_exact(
&mut self,
buf: &mut [u8]
) -> Result<(), ReadExactError<Self::Error>>
buf
.