Struct grep_searcher::sinks::UTF8
source · pub struct UTF8<F>(pub F)
where
F: FnMut(u64, &str) -> Result<bool, Error>;
Expand description
A sink that provides line numbers and matches as strings while ignoring everything else.
This implementation will return an error if a match contains invalid
UTF-8 or if the searcher was not configured to count lines. Errors
on invalid UTF-8 can be suppressed by using the Lossy
sink instead
of this one.
The closure accepts two parameters: a line number and a UTF-8 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 UTF8<F>
impl<F> Sink for UTF8<F>
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> Freeze for UTF8<F>where
F: Freeze,
impl<F> RefUnwindSafe for UTF8<F>where
F: RefUnwindSafe,
impl<F> Send for UTF8<F>where
F: Send,
impl<F> Sync for UTF8<F>where
F: Sync,
impl<F> Unpin for UTF8<F>where
F: Unpin,
impl<F> UnwindSafe for UTF8<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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)