pub struct LimitReader { /* private fields */ }
Expand description
The LimitReader
reads into buf
which is held within the record struct.
Implementations§
Source§impl LimitReader
impl LimitReader
Sourcepub const DEFAULT_BUF_SIZE: usize = 1_024usize
pub const DEFAULT_BUF_SIZE: usize = 1_024usize
Default buffer size for the internal LimitReader
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new LimitReader
with a LimitReader::DEFAULT_BUF_SIZE
for the limit-readers max threshold.
Sourcepub fn limit(&mut self, limit: u64) -> &mut Self
pub fn limit(&mut self, limit: u64) -> &mut Self
Increase the allowed limit on the LimitReader
Sourcepub fn enable_decode_zlib(&mut self) -> &mut Self
pub fn enable_decode_zlib(&mut self) -> &mut Self
Enable decoding from compressed Zlib
Sourcepub fn read(&mut self, source: PathBuf) -> Result<usize>
pub fn read(&mut self, source: PathBuf) -> Result<usize>
Read from provided source file. If the source data is already Zlib compressed, optionally decode the data stream before reading it through a limit-reader.
§Panics
If the provided source file does not exist or is inaccessible, it will panic. Refer to std::fs::File::open
for details. This will return LimitReaderError
.
§Errors
If this function encounters an error of the kind LimitReaderError
, this error will be returned.
Sourcepub fn read_limited(&mut self, source: PathBuf) -> Result<LimitReaderOutput>
pub fn read_limited(&mut self, source: PathBuf) -> Result<LimitReaderOutput>
Given an accessible source file, this will automatically limit the contents read to the size of the buffer itself. This will silently truncate read bytes into the buffer, without raising an error.
§Errors
If this function encounters an error of the kind LimitReaderError
, this error will be returned.