Struct embedded_tls::TlsConnection
source · pub struct TlsConnection<'a, Socket, CipherSuite>where
Socket: AsyncRead + AsyncWrite + '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: AsyncRead + AsyncWrite + 'a,
CipherSuite: TlsCipherSuite + 'static,
impl<'a, Socket, CipherSuite> TlsConnection<'a, Socket, CipherSuite>where
Socket: AsyncRead + AsyncWrite + '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 async 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 async fn open<'m, RNG: CryptoRng + RngCore + 'm, Verifier: TlsVerifier<CipherSuite> + 'm>(
&mut self,
context: TlsContext<'m, CipherSuite, RNG>
) -> Result<(), TlsError>where
'a: 'm,
pub async fn open<'m, RNG: CryptoRng + RngCore + 'm, Verifier: TlsVerifier<CipherSuite> + 'm>(
&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 async fn write(&mut self, buf: &[u8]) -> Result<usize, TlsError>
pub async 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: AsyncRead + AsyncWrite + 'a,
CipherSuite: TlsCipherSuite + 'static,
impl<'a, Socket, CipherSuite> Io for TlsConnection<'a, Socket, CipherSuite>where
Socket: AsyncRead + AsyncWrite + 'a,
CipherSuite: TlsCipherSuite + 'static,
source§impl<'a, Socket, CipherSuite> Read for TlsConnection<'a, Socket, CipherSuite>where
Socket: AsyncRead + AsyncWrite + 'a,
CipherSuite: TlsCipherSuite + 'static,
impl<'a, Socket, CipherSuite> Read for TlsConnection<'a, Socket, CipherSuite>where
Socket: AsyncRead + AsyncWrite + 'a,
CipherSuite: TlsCipherSuite + 'static,
source§async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
source§async fn read_exact(
&mut self,
buf: &mut [u8]
) -> impl Future<Output = Result<(), ReadExactError<Self::Error>>>
async fn read_exact(
&mut self,
buf: &mut [u8]
) -> impl Future<Output = Result<(), ReadExactError<Self::Error>>>
buf
.