Struct LimitReader

Source
pub struct LimitReader { /* private fields */ }
Expand description

The LimitReader reads into buf which is held within the record struct.

Implementations§

Source§

impl LimitReader

Source

pub const DEFAULT_BUF_SIZE: usize = 1_024usize

Default buffer size for the internal LimitReader

Source

pub fn new() -> Self

Create a new LimitReader with a LimitReader::DEFAULT_BUF_SIZE for the limit-readers max threshold.

Source

pub fn buffer(&self) -> &[u8; 1024]

Return a reference to the internal buffer.

Source

pub fn limit(&mut self, limit: u64) -> &mut Self

Increase the allowed limit on the LimitReader

Source

pub fn enable_decode_zlib(&mut self) -> &mut Self

Enable decoding from compressed Zlib

Source

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.

Source

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.

Trait Implementations§

Source§

impl Default for LimitReader

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.