Struct grep_printer::JSONSink
source · pub struct JSONSink<'p, 's, M: Matcher, W> { /* private fields */ }
serde
only.Expand description
An implementation of Sink
associated with a matcher and an optional file
path for the JSON printer.
This type is generic over a few type parameters:
'p
refers to the lifetime of the file path, if one is provided. When no file path is given, then this is'static
.'s
refers to the lifetime of theJSON
printer that this type borrows.M
refers to the type of matcher used bygrep_searcher::Searcher
that is reporting results to this sink.W
refers to the underlying writer that this printer is writing its output to.
Implementations§
source§impl<'p, 's, M: Matcher, W: Write> JSONSink<'p, 's, M, W>
impl<'p, 's, M: Matcher, W: Write> JSONSink<'p, 's, M, W>
sourcepub fn has_match(&self) -> bool
pub fn has_match(&self) -> bool
Returns true if and only if this printer received a match in the previous search.
This is unaffected by the result of searches before the previous search.
sourcepub fn match_count(&self) -> u64
pub fn match_count(&self) -> u64
Return the total number of matches reported to this sink.
This corresponds to the number of times Sink::matched
is called.
sourcepub fn binary_byte_offset(&self) -> Option<u64>
pub fn binary_byte_offset(&self) -> Option<u64>
If binary data was found in the previous search, this returns the offset at which the binary data was first detected.
The offset returned is an absolute offset relative to the entire set of bytes searched.
This is unaffected by the result of searches before the previous
search. e.g., If the search prior to the previous search found binary
data but the previous search found no binary data, then this will
return None
.
Trait Implementations§
source§impl<'p, 's, M: Matcher, W: Write> Sink for JSONSink<'p, 's, M, W>
impl<'p, 's, M: Matcher, W: Write> Sink for JSONSink<'p, 's, M, W>
source§fn matched(
&mut self,
searcher: &Searcher,
mat: &SinkMatch<'_>,
) -> Result<bool, Error>
fn matched( &mut self, searcher: &Searcher, mat: &SinkMatch<'_>, ) -> Result<bool, Error>
source§fn context(
&mut self,
searcher: &Searcher,
ctx: &SinkContext<'_>,
) -> Result<bool, Error>
fn context( &mut self, searcher: &Searcher, ctx: &SinkContext<'_>, ) -> Result<bool, Error>
true
. Read more