Skip to main content

read_exact_span

Function read_exact_span 

Source
pub fn read_exact_span<R, const N: usize>(
    reader: &mut R,
) -> Result<SpanBuffer<N>, AescryptError>
where R: Read,
Expand description

Reads exactly N bytes from reader into a fresh auto-zeroizing SpanBuffer<N>.

read_exact_span is the primary stream reader for the constant-memory decryption path. The returned buffer lives on the stack inside a secure-gate wrapper so its contents are wiped on drop — important because pre-authentication header bytes pass through this function.

§Errors

  • AescryptError::Ioreader.read_exact returned an error, including premature EOF.

§Panics

Never panics. EOF is surfaced as AescryptError::Io, not a panic.

§Security

Output buffer auto-zeroizes via secure-gate regardless of which branch of the caller eventually returns.