pub struct Writer<W, const CHUNK: usize> { /* private fields */ }Available on crate features
allow-non-fips and std only.Expand description
A wrapper for any implementor of std::io::Write.
Writer implements std::io::Write and takes a child which also implements this trait.
This type can wrap any writer, and ensure all data passed to said writer is encrypted.
Implementations§
Methods from Deref<Target = ChaCha20<Streaming>>§
Sourcepub fn decrypt_into(
&mut self,
cipher: &[u8],
plain: &mut [u8],
) -> Result<(), Unspecified>
pub fn decrypt_into( &mut self, cipher: &[u8], plain: &mut [u8], ) -> Result<(), Unspecified>
Sourcepub fn decrypt_in_place<'io>(
&mut self,
in_out: &'io mut [u8],
) -> Result<&'io [u8], Unspecified>
pub fn decrypt_in_place<'io>( &mut self, in_out: &'io mut [u8], ) -> Result<&'io [u8], Unspecified>
Sourcepub fn decrypt_into_sized<const I: usize, const O: usize>(
&mut self,
cipher: &[u8; I],
plain: &mut [u8; O],
) -> Result<(), Unspecified>
pub fn decrypt_into_sized<const I: usize, const O: usize>( &mut self, cipher: &[u8; I], plain: &mut [u8; O], ) -> Result<(), Unspecified>
Sourcepub fn decrypt_in_place_sized<'io, const C: usize>(
&mut self,
in_out: &'io mut [u8; C],
) -> Result<&'io [u8; C], Unspecified>
pub fn decrypt_in_place_sized<'io, const C: usize>( &mut self, in_out: &'io mut [u8; C], ) -> Result<&'io [u8; C], Unspecified>
Sourcepub fn decrypt_into_exact<const C: usize>(
&mut self,
cipher: &[u8; C],
plain: &mut [u8; C],
) -> Result<(), Unspecified>
pub fn decrypt_into_exact<const C: usize>( &mut self, cipher: &[u8; C], plain: &mut [u8; C], ) -> Result<(), Unspecified>
Sourcepub fn decrypt(&mut self, cipher: &[u8]) -> Result<Vec<u8>, Unspecified>
Available on crate feature alloc only.
pub fn decrypt(&mut self, cipher: &[u8]) -> Result<Vec<u8>, Unspecified>
alloc only.Sourcepub fn decrypt_exact<const O: usize>(
&mut self,
cipher: &[u8; O],
) -> Result<[u8; O], Unspecified>
pub fn decrypt_exact<const O: usize>( &mut self, cipher: &[u8; O], ) -> Result<[u8; O], Unspecified>
Sourcepub fn encrypt_into(
&mut self,
plain: &[u8],
cipher: &mut [u8],
) -> Result<(), Unspecified>
pub fn encrypt_into( &mut self, plain: &[u8], cipher: &mut [u8], ) -> Result<(), Unspecified>
Sourcepub fn encrypt_into_sized<const I: usize, const O: usize>(
&mut self,
plain: &[u8; I],
cipher: &mut [u8; O],
) -> Result<(), Unspecified>
pub fn encrypt_into_sized<const I: usize, const O: usize>( &mut self, plain: &[u8; I], cipher: &mut [u8; O], ) -> Result<(), Unspecified>
Sourcepub fn encrypt_into_exact<const C: usize>(
&mut self,
input: &[u8; C],
output: &mut [u8; C],
) -> Result<(), Unspecified>
pub fn encrypt_into_exact<const C: usize>( &mut self, input: &[u8; C], output: &mut [u8; C], ) -> Result<(), Unspecified>
Encrypts the input into the output buffer in streaming mode with exact sizes.
§Type Parameters
C- The size of both the input and output arrays.
§Arguments
input- The input array to encrypt.output- The array to store the encrypted data.
§Errors
C (the length of input and output) was greater than u32::MAX.
Trait Implementations§
Source§impl<W: Write, const CHUNK: usize> Write for Writer<W, CHUNK>
impl<W: Write, const CHUNK: usize> Write for Writer<W, CHUNK>
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Encrypts and writes the given buffer.
§Arguments
buf- The buffer to encrypt and write.
§Returns
The number of bytes written on success, or an io::Error on failure.
§Note
The maximum number of bytes this can write in a single invocation is capped by the
CHUNK size. If this is not desirable, please consider using the write_all
implementation.
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Flushes the underlying writer.
§Returns
Propagates the result of invoking flush for the underlying writer
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector)Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
write_all_vectored)Attempts to write multiple buffers into this writer. Read more
Auto Trait Implementations§
impl<W, const CHUNK: usize> Freeze for Writer<W, CHUNK>where
W: Freeze,
impl<W, const CHUNK: usize> RefUnwindSafe for Writer<W, CHUNK>where
W: RefUnwindSafe,
impl<W, const CHUNK: usize> Send for Writer<W, CHUNK>where
W: Send,
impl<W, const CHUNK: usize> Sync for Writer<W, CHUNK>where
W: Sync,
impl<W, const CHUNK: usize> Unpin for Writer<W, CHUNK>where
W: Unpin,
impl<W, const CHUNK: usize> UnwindSafe for Writer<W, CHUNK>where
W: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more