pub fn encrypted_stream<R: AsyncRead, W: AsyncWrite, A, S>(
    read: R,
    write: W,
    key: &GenericArray<u8, A::KeySize>,
    nonce: &GenericArray<u8, NonceSize<A, S>>
) -> (ReadHalf<R, Decryptor<A, S>>, WriteHalf<W, Encryptor<A, S>>)where
    S: StreamPrimitive<A> + NewStream<A>,
    A: AeadInPlace + KeyInit,
    A::NonceSize: Sub<<S as StreamPrimitive<A>>::NonceOverhead>,
    NonceSize<A, S>: ArrayLength<u8>,
Expand description

Creates a pair of ReadHalf and WriteHalf with default buffer size of self::DEFAULT_BUFFER_SIZE and chunk size of self::DEFAULT_CHUNK_SIZE

use chacha20poly1305::aead::stream::{DecryptorLE31, EncryptorLE31};
use chacha20poly1305::XChaCha20Poly1305;

use async_encrypted_stream::{ReadHalf, WriteHalf, encrypted_stream};

let key = [0u8; 32];
let nonce = [0u8; 20];

let (rx, tx) = tokio::io::duplex(4096);
let (mut reader, mut writer): (
    ReadHalf<_, DecryptorLE31<XChaCha20Poly1305>>,
    WriteHalf<_, EncryptorLE31<XChaCha20Poly1305>>,
) = encrypted_stream(rx, tx, key.as_ref().into(), nonce.as_ref().into());