Struct blockwise_reader::BlockWiseReader
source · 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>
impl<'a> BlockWiseReader<'a>
sourcepub fn available_bytes(&self) -> usize
pub fn available_bytes(&self) -> usize
bytes from the current pos position to the end of the internal vector
sourcepub fn size(&self) -> usize
pub fn size(&self) -> usize
overall size of the internal vector, is the same as available_bytes() + pos_get()
sourcepub fn slurp(&mut self, bytecount: usize) -> Result<usize, Error>
pub fn slurp(&mut self, bytecount: usize) -> Result<usize, Error>
Tries to continue reading bytes from the stream, so that at least bytecount bytes from the current position ahead are available. This doesn’t man it reads exactly bytecount bytes if there already bytes available. It can also happen that it reads lesser than needed if it encounters an end of file. Returns the amount of available bytes starting at pos.
sourcepub fn slurp_loop(&mut self, buffersize: usize) -> Result<usize, Error>
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.
sourcepub fn search(&self, bytes: &[u8]) -> Option<usize>
pub fn search(&self, bytes: &[u8]) -> Option<usize>
searches a byte slice in the available bytes
sourcepub fn pos_add_i(&mut self, pos: isize)
pub fn pos_add_i(&mut self, pos: isize)
adds to the internal position a positive or negative value
sourcepub fn pos_cut(&mut self) -> Vec<u8>
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
sourcepub fn pos_inject(&mut self, s: &[u8])
pub fn pos_inject(&mut self, s: &[u8])
copies the data of the slice s at the position pos
sourcepub fn get_back(&self, back: usize) -> &[u8] ⓘ
pub fn get_back(&self, back: usize) -> &[u8] ⓘ
returns all data from pos - back to pos of the internal vector
sourcepub fn get_from(&self, pos: usize) -> &[u8] ⓘ
pub fn get_from(&self, pos: usize) -> &[u8] ⓘ
returns all data from the given pos to the end of the internal vector
sourcepub fn get_from_to_current(&self, pos: usize) -> &[u8] ⓘ
pub fn get_from_to_current(&self, pos: usize) -> &[u8] ⓘ
returns all data from the given pos to the internal pos
sourcepub fn slurp_match_repos(&mut self, marker_str: &[u8]) -> Result<bool, Error>
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
sourcepub fn match_back(&self, marker_str: &[u8]) -> bool
pub fn match_back(&self, marker_str: &[u8]) -> bool
matches a fixed string from pos - marker_str.len() to pos, returns true if matched
sourcepub fn slurp_find_repos1(
&mut self,
bytecount: usize,
e: u8
) -> Result<bool, Error>
pub fn slurp_find_repos1( &mut self, bytecount: usize, e: u8 ) -> Result<bool, Error>
Convenience method, calls self.slurp_find_repos(bytecount, e, FindPos::End).
sourcepub fn slurp_find_repos0(
&mut self,
bytecount: usize,
e: u8
) -> Result<bool, Error>
pub fn slurp_find_repos0( &mut self, bytecount: usize, e: u8 ) -> Result<bool, Error>
Convenience method, calls self.slurp_find_repos(bytecount, e, FindPos::Begin).
sourcepub fn slurp_find_repos(
&mut self,
bytecount: usize,
e: u8,
fp: FindPos
) -> Result<bool, Error>
pub fn slurp_find_repos( &mut self, bytecount: usize, e: u8, fp: FindPos ) -> Result<bool, Error>
Slurps bytecount bytes. Sets pos regarding the fp flag if the byte was found in the available bytes. If nothing was found pos remains unaltered. Returns true if something was found, false otherwise.
sourcepub fn slurp_find_multiple_repos(
&mut self,
bytecount: usize,
se: &[u8],
cut: bool,
fp: FindPos
) -> Result<bool, Error>
pub fn slurp_find_multiple_repos( &mut self, bytecount: usize, se: &[u8], cut: bool, fp: FindPos ) -> Result<bool, Error>
Slurps bytecount bytes. Sets pos regarding the fp flag if the byte was found in the available bytes. Finds the nearest byte if cut is false, otherwise stops iterating over se if the current byte was found. If nothing was found pos remains unaltered. Returns true if something was found, false otherwise.
sourcepub fn slurp_find_multiple_repos_idx(
&mut self,
bytecount: usize,
se: &[u8],
cut: bool,
fp: FindPos
) -> Result<Option<PatternIdx>, Error>
pub fn slurp_find_multiple_repos_idx( &mut self, bytecount: usize, se: &[u8], cut: bool, fp: FindPos ) -> Result<Option<PatternIdx>, Error>
Slurps bytecount bytes. Sets pos regarding the fp flag if the byte was found in the available bytes. Finds the nearest byte if cut is false, otherwise stops iterating over se if the current byte was found. If nothing was found pos remains unaltered. Returns the index of se if something was found.
sourcepub fn slurp_search_repos0(
&mut self,
bytecount: usize,
bytes: &[u8]
) -> Result<bool, Error>
pub fn slurp_search_repos0( &mut self, bytecount: usize, bytes: &[u8] ) -> Result<bool, Error>
Convenience method, calls self.slurp_search_repos(bytecount, bytes, FindPos::Begin).
sourcepub fn slurp_search_repos1(
&mut self,
bytecount: usize,
bytes: &[u8]
) -> Result<bool, Error>
pub fn slurp_search_repos1( &mut self, bytecount: usize, bytes: &[u8] ) -> Result<bool, Error>
Convenience method, calls self.slurp_search_repos(bytecount, bytes, FindPos::End).
sourcepub fn slurp_search_repos(
&mut self,
bytecount: usize,
bytes: &[u8],
fp: FindPos
) -> Result<bool, Error>
pub fn slurp_search_repos( &mut self, bytecount: usize, bytes: &[u8], fp: FindPos ) -> Result<bool, Error>
Slurps bytecount bytes. Sets pos regarding the fp flag if the byte slice was found in the available bytes. If nothing was found pos remains unaltered. Returns true if something was found, false otherwise.
sourcepub fn slurp_search_multiple_repos_idx(
&mut self,
bytecount: usize,
sbytes: &[&[u8]],
cut: bool,
fp: FindPos
) -> Result<Option<PatternIdx>, Error>
pub fn slurp_search_multiple_repos_idx( &mut self, bytecount: usize, sbytes: &[&[u8]], cut: bool, fp: FindPos ) -> Result<Option<PatternIdx>, Error>
Slurps bytecount bytes. Sets pos regarding the fp flag if the byte slice was found in the available bytes. Finds the nearest byte slice if cut is false, otherwise stops iterating over sbytes if the current byte slice was found. If nothing was found pos remains unaltered. Returns the index of sbytes if something was found.
sourcepub fn slurp_find_repos_loop(
&mut self,
buffersize: usize,
e: u8,
fp: FindPos
) -> Result<bool, Error>
pub fn slurp_find_repos_loop( &mut self, buffersize: usize, e: u8, fp: FindPos ) -> Result<bool, Error>
Applies self.slurp_find_repos in a loop up to end of file or the pattern was found.
sourcepub fn slurp_search_repos_loop(
&mut self,
buffersize: usize,
bytes: &[u8],
fp: FindPos
) -> Result<bool, Error>
pub fn slurp_search_repos_loop( &mut self, buffersize: usize, bytes: &[u8], fp: FindPos ) -> Result<bool, Error>
Applies self.slurp_search_repos in a loop up to end of file or the pattern was found. The buffer must be bigger than the byte slice.
sourcepub fn slurp_find_multiple_repos_loop_idx(
&mut self,
buffersize: usize,
se: &[u8],
cut: bool,
fp: FindPos
) -> Result<Option<PatternIdx>, Error>
pub fn slurp_find_multiple_repos_loop_idx( &mut self, buffersize: usize, se: &[u8], cut: bool, fp: FindPos ) -> Result<Option<PatternIdx>, Error>
Applies self.slurp_find_multiple_repos_idx in a loop up to end of file or the pattern was found. The buffer must be bigger than the byte slice.
sourcepub fn slurp_search_multiple_repos_loop_idx(
&mut self,
buffersize: usize,
sbytes: &[&[u8]],
cut: bool,
fp: FindPos
) -> Result<Option<PatternIdx>, Error>
pub fn slurp_search_multiple_repos_loop_idx( &mut self, buffersize: usize, sbytes: &[&[u8]], cut: bool, fp: FindPos ) -> Result<Option<PatternIdx>, Error>
Applies self.slurp_search_multiple_repos_idx in a loop up to end of file or the pattern was found. The buffer must be bigger than the byte slice.