pub struct BlockWiseReader<'a> { /* private fields */ }
Expand description

The BlockWiseReader holds the data which are read in to a specific point and a reader to read from

Implementations§

source§

impl<'a> BlockWiseReader<'a>

source

pub fn new(r: Box<dyn Read + 'a>) -> Self

creates a new BlockWiseReader from the given reader

source

pub fn available_bytes(&self) -> usize

bytes from the current pos position to the end of the internal vector

source

pub fn size(&self) -> usize

overall size of the internal vector, is the same as available_bytes() + pos_get()

source

pub fn slurp(&mut self, bytecount: usize) -> Result<usize, Error>

Reads bytecount bytes from the stream and returns the amount of available bytes starting at pos, which can be more than bytecount when subsequently already read more, but also less if there were not enough available.

source

pub fn slurp_loop(&mut self, buffersize: usize) -> Result<usize, Error>

Reads bytes from the stream in buffersize steps as long as there are bytes available.

source

pub fn find(&self, e: u8) -> Option<usize>

searches a byte in the available bytes

source

pub fn search(&self, bytes: &[u8]) -> Option<usize>

searches a byte slice in the available bytes

source

pub fn pos_set(&mut self, pos: usize)

sets the internal position

source

pub fn pos_add(&mut self, pos: usize)

adds to the internal position

source

pub fn pos_sub(&mut self, pos: usize)

subtracts from the internal position

source

pub fn pos_add_i(&mut self, pos: isize)

adds to the internal position a positive or negative value

source

pub fn pos_cut(&mut self) -> Vec<u8>

removes all elements form the beginning of the internal vector to pos and returns the removed elements

source

pub fn pos_inject(&mut self, s: &[u8])

copies the data of the slice s at the position pos

source

pub fn get(&self) -> &[u8]

returns all data from pos to the end of the internal vector

source

pub fn get_back(&self, back: usize) -> &[u8]

returns all data from pos - back to pos of the internal vector

source

pub fn get_from(&self, pos: usize) -> &[u8]

returns all data from the given pos to the end of the internal vector

source

pub fn get_from_to_current(&self, pos: usize) -> &[u8]

returns all data from the given pos to the internal pos

source

pub fn slurp_match_repos(&mut self, marker_str: &[u8]) -> Result<bool, Error>

slurps as much as the marker_str is long and returns true if the content is the same as the marker_str, repositions the current position to the end of the marker

source

pub fn match_back(&self, marker_str: &[u8]) -> bool

matches a fixed string from pos - marker_str.len() to pos, returns true if matched

source

pub fn slurp_find_repos1( &mut self, bytecount: usize, e: u8 ) -> Result<bool, Error>

Sets pos to find position + 1 if the byte was found in the available bytes. If nothing was found pos remains unaltered.

source

pub fn slurp_find_repos0( &mut self, bytecount: usize, e: u8 ) -> Result<bool, Error>

Sets pos to find position if the byte was found in the available bytes. If nothing was found pos remains unaltered.

source

pub fn slurp_find_repos( &mut self, bytecount: usize, e: u8, fp: FindPos ) -> Result<bool, Error>

Sets pos regarding the fp flag if the byte was found in the available bytes. If nothing was found pos remains unaltered.

source

pub fn slurp_find_multiple_repos( &mut self, bytecount: usize, se: &[u8], cut: bool, fp: FindPos ) -> Result<bool, Error>

Sets pos regarding the fp flag if one of the the bytes was found in the available bytes. If nothing was found pos remains unaltered. Finds the nearest byte if cut is false. The parameter cut stops searching if a byte was found.

source

pub fn slurp_find_multiple_repos_idx( &mut self, bytecount: usize, se: &[u8], cut: bool, fp: FindPos ) -> Result<Option<PatternIdx>, Error>

Sets pos regarding the fp flag if one of the the bytes was found in the available bytes. If nothing was found pos remains unaltered. Finds the nearest byte if cut is false. The parameter cut stops searching if a byte was found. Returns the idx of the matched pattern.

source

pub fn pos_get(&self) -> usize

the current internal position value

source

pub fn slurp_search_repos0( &mut self, bytecount: usize, bytes: &[u8] ) -> Result<bool, Error>

Sets pos to find position if the byte slice was found in the available bytes. If nothing was found pos remains unaltered.

source

pub fn slurp_search_repos1( &mut self, bytecount: usize, bytes: &[u8] ) -> Result<bool, Error>

Sets pos after find position if the byte slice was found in the available bytes. If nothing was found pos remains unaltered.

source

pub fn slurp_search_repos( &mut self, bytecount: usize, bytes: &[u8], fp: FindPos ) -> Result<bool, Error>

Sets pos regarding the fp flag find position if the byte slice was found in the available bytes. If nothing was found pos remains unaltered.

source

pub fn slurp_search_multiple_repos_idx( &mut self, bytecount: usize, sbytes: &[&[u8]], cut: bool, fp: FindPos ) -> Result<Option<PatternIdx>, Error>

Sets pos regarding the fp flag if one of the the bytes was found in the available bytes. If nothing was found pos remains unaltered. Finds the nearest byte slice if cut is false. The parameter cut stops searching if a byte slice was found. Returns the idx of the matched pattern.

source

pub fn slurp_find_repos_loop( &mut self, buffersize: usize, e: u8, fp: FindPos ) -> Result<bool, Error>

Reads bytes from the stream in buffersize steps as long as there are bytes available to the point where the char was found.

source

pub fn slurp_search_repos_loop( &mut self, buffersize: usize, bytes: &[u8], fp: FindPos ) -> Result<bool, Error>

Reads bytes from the stream in buffersize steps as long as there are bytes available to the point where the byte slice was found. The buffer must be bigger than the byte slice.

source

pub fn slurp_search_multiple_repos_loop_idx( &mut self, buffersize: usize, sbytes: &[&[u8]], cut: bool, fp: FindPos ) -> Result<Option<PatternIdx>, Error>

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for BlockWiseReader<'a>

§

impl<'a> !Send for BlockWiseReader<'a>

§

impl<'a> !Sync for BlockWiseReader<'a>

§

impl<'a> Unpin for BlockWiseReader<'a>

§

impl<'a> !UnwindSafe for BlockWiseReader<'a>

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>,

§

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>,

§

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.