Struct grep_searcher::sinks::Bytes
source · pub struct Bytes<F>(pub F)
where
F: FnMut(u64, &[u8]) -> Result<bool, Error>;
Expand description
A sink that provides line numbers and matches as raw bytes while ignoring everything else.
This implementation will return an error on the first match if the searcher was not configured to count lines.
The closure accepts two parameters: a line number and a raw byte string
containing the matched data. The closure returns a
Result<bool, std::io::Error>
. If the bool
is false
, then the
search stops immediately. Otherwise, searching continues.
If multi line mode was enabled, the line number refers to the line number of the first line in the match.
Tuple Fields§
§0: F
Trait Implementations§
source§impl<F> Sink for Bytes<F>where
F: FnMut(u64, &[u8]) -> Result<bool, Error>,
impl<F> Sink for Bytes<F>where F: FnMut(u64, &[u8]) -> Result<bool, Error>,
source§fn matched(
&mut self,
_searcher: &Searcher,
mat: &SinkMatch<'_>
) -> Result<bool, Error>
fn matched( &mut self, _searcher: &Searcher, mat: &SinkMatch<'_> ) -> Result<bool, Error>
This method is called whenever a match is found. Read more
source§fn context(
&mut self,
_searcher: &Searcher,
_context: &SinkContext<'_>
) -> Result<bool, Self::Error>
fn context( &mut self, _searcher: &Searcher, _context: &SinkContext<'_> ) -> Result<bool, Self::Error>
This method is called whenever a context line is found, and is optional
to implement. By default, it does nothing and returns
true
. Read moresource§fn context_break(&mut self, _searcher: &Searcher) -> Result<bool, Self::Error>
fn context_break(&mut self, _searcher: &Searcher) -> Result<bool, Self::Error>
This method is called whenever a break in contextual lines is found,
and is optional to implement. By default, it does nothing and returns
true
. Read moresource§fn binary_data(
&mut self,
_searcher: &Searcher,
_binary_byte_offset: u64
) -> Result<bool, Self::Error>
fn binary_data( &mut self, _searcher: &Searcher, _binary_byte_offset: u64 ) -> Result<bool, Self::Error>
This method is called whenever binary detection is enabled and binary
data is found. If binary data is found, then this is called at least
once for the first occurrence with the absolute byte offset at which
the binary data begins. Read more
Auto Trait Implementations§
impl<F> RefUnwindSafe for Bytes<F>where F: RefUnwindSafe,
impl<F> Send for Bytes<F>where F: Send,
impl<F> Sync for Bytes<F>where F: Sync,
impl<F> Unpin for Bytes<F>where F: Unpin,
impl<F> UnwindSafe for Bytes<F>where F: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more