Trait async_psec::PsecReader [−][src]
pub trait PsecReader {
fn set_max_recv_size(&mut self, size: usize, is_raw_size: bool);
#[must_use]
fn receive_and_decrypt<'life0, 'async_trait>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, PsecError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
#[must_use]
fn into_receive_and_decrypt<'async_trait>(
self
) -> Pin<Box<dyn Future<Output = (Result<Vec<u8>, PsecError>, Self)> + Send + 'async_trait>>
where
Self: 'async_trait;
}Expand description
Read from a PSEC session.
Required methods
fn set_max_recv_size(&mut self, size: usize, is_raw_size: bool)[src]
fn set_max_recv_size(&mut self, size: usize, is_raw_size: bool)[src]Set the maximum size of an acceptable buffer being received.
Any received buffer larger than this value will be discarded and a BufferTooLarge error will be returned. Then, the PSEC session should be closed to prevent any DOS attacks.
If is_raw_size is set to true, the specified size will correspond to the maximum encrypted buffer size, including potential padding. Otherwise, the maximum buffer size will correspond to the length of a message of this size after applying padding and encryption.
The default value is 32 768 020, which allows to receive any messages under 32 768 000 bytes.
#[must_use]fn receive_and_decrypt<'life0, 'async_trait>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, PsecError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait, [src]
#[must_use]fn receive_and_decrypt<'life0, 'async_trait>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, PsecError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait, [src]Read then decrypt from a PSEC session.
Panic
Panics if the PSEC handshake is not finished and successful.
#[must_use]fn into_receive_and_decrypt<'async_trait>(
self
) -> Pin<Box<dyn Future<Output = (Result<Vec<u8>, PsecError>, Self)> + Send + 'async_trait>> where
Self: 'async_trait, [src]
#[must_use]fn into_receive_and_decrypt<'async_trait>(
self
) -> Pin<Box<dyn Future<Output = (Result<Vec<u8>, PsecError>, Self)> + Send + 'async_trait>> where
Self: 'async_trait, [src]Take ownership of the PsecReader, read, decrypt, then return back the PsecReader. Useful when used with tokio::select!.
Panic
Panics if the PSEC handshake is not finished and successful.
let receiving = psec_session.into_receive_and_decrypt(); tokio::pin!(receiving); loop { tokio::select! { result = &mut receiving => { let (buffer, psec_session) = result; receiving.set(psec_session.into_receive_and_decrypt()); match buffer { Ok(buffer) => println!("Received: {:?}", buffer), Err(e) => println!("Error: {}", e) } } //other select! branches... } }
Implementors
impl PsecReader for Session[src]
impl PsecReader for Session[src]fn set_max_recv_size(&mut self, size: usize, is_raw_size: bool)[src]
fn receive_and_decrypt<'life0, 'async_trait>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, PsecError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait, [src]
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, PsecError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn into_receive_and_decrypt<'async_trait>(
self
) -> Pin<Box<dyn Future<Output = (Result<Vec<u8>, PsecError>, Self)> + Send + 'async_trait>> where
Self: 'async_trait, [src]
self
) -> Pin<Box<dyn Future<Output = (Result<Vec<u8>, PsecError>, Self)> + Send + 'async_trait>> where
Self: 'async_trait,
impl PsecReader for SessionReadHalf[src]
impl PsecReader for SessionReadHalf[src]fn set_max_recv_size(&mut self, size: usize, is_raw_size: bool)[src]
fn receive_and_decrypt<'life0, 'async_trait>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, PsecError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait, [src]
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, PsecError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn into_receive_and_decrypt<'async_trait>(
self
) -> Pin<Box<dyn Future<Output = (Result<Vec<u8>, PsecError>, Self)> + Send + 'async_trait>> where
Self: 'async_trait, [src]
self
) -> Pin<Box<dyn Future<Output = (Result<Vec<u8>, PsecError>, Self)> + Send + 'async_trait>> where
Self: 'async_trait,