Skip to main content

read_capped

Function read_capped 

Source
pub fn read_capped<R: Read>(
    reader: R,
    limit: u64,
) -> Result<Vec<u8>, PathSecurityError>
Expand description

Read at most limit bytes from reader, erroring if more are available.

This bounds memory use for streamed inputs (e.g. standard input) where no size is known in advance.

ยงErrors

Returns PathSecurityError::TooLarge if reader yields more than limit bytes, or PathSecurityError::Io on an underlying read error.