Struct drogue_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
sourceimpl<'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 + 'static, Clock: TlsClock + 'static, const CERT_SIZE: usize>(
&mut self,
context: TlsContext<'m, CipherSuite, RNG>
) -> Result<(), TlsError> where
'a: 'm,
pub async fn open<'m, RNG: CryptoRng + RngCore + 'static, 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 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.
Auto Trait Implementations
impl<'a, Socket, CipherSuite> RefUnwindSafe for TlsConnection<'a, Socket, CipherSuite> where
Socket: RefUnwindSafe,
<<<CipherSuite as TlsCipherSuite>::Hash as BlockInput>::BlockSize as ArrayLength<u8>>::ArrayType: RefUnwindSafe,
<<<CipherSuite as TlsCipherSuite>::Hash as FixedOutput>::OutputSize as ArrayLength<u8>>::ArrayType: RefUnwindSafe,
<CipherSuite as TlsCipherSuite>::Hash: RefUnwindSafe,
<CipherSuite as TlsCipherSuite>::IvLen: RefUnwindSafe,
<CipherSuite as TlsCipherSuite>::KeyLen: RefUnwindSafe,
impl<'a, Socket, CipherSuite> Send for TlsConnection<'a, Socket, CipherSuite> where
Socket: Send,
<CipherSuite as TlsCipherSuite>::Hash: Send,
<CipherSuite as TlsCipherSuite>::IvLen: Send,
<CipherSuite as TlsCipherSuite>::KeyLen: Send,
impl<'a, Socket, CipherSuite> Sync for TlsConnection<'a, Socket, CipherSuite> where
Socket: Sync,
<CipherSuite as TlsCipherSuite>::Hash: Sync,
<CipherSuite as TlsCipherSuite>::IvLen: Sync,
<CipherSuite as TlsCipherSuite>::KeyLen: Sync,
impl<'a, Socket, CipherSuite> Unpin for TlsConnection<'a, Socket, CipherSuite> where
Socket: Unpin,
<<<CipherSuite as TlsCipherSuite>::Hash as BlockInput>::BlockSize as ArrayLength<u8>>::ArrayType: Unpin,
<<<CipherSuite as TlsCipherSuite>::Hash as FixedOutput>::OutputSize as ArrayLength<u8>>::ArrayType: Unpin,
<CipherSuite as TlsCipherSuite>::Hash: Unpin,
<CipherSuite as TlsCipherSuite>::IvLen: Unpin,
<CipherSuite as TlsCipherSuite>::KeyLen: Unpin,
impl<'a, Socket, CipherSuite> !UnwindSafe for TlsConnection<'a, Socket, CipherSuite>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more