ffsend_api/pipe/crypto/traits.rs
1//! Cryptographic pipe traits.
2
3use crate::pipe::Pipe;
4
5/// Pipe specialisation trait for cryptographic pipes.
6pub trait Crypt: Pipe {
7 /// Encrypt/decrypt bytes from `input`, return the result.
8 ///
9 /// Read bytes from the given input buffer, transform it using the configured cryptography and
10 /// return transformed data when available.
11 ///
12 /// This returns a tuple with the number of bytes read from the `input`, along with transformed
13 /// data if available in the following format: `(read_bytes, transformed_data)`.
14 #[inline(always)]
15 fn crypt(&mut self, input: &[u8]) -> (usize, Option<Vec<u8>>) {
16 self.pipe(input)
17 }
18}