pub struct MaxCount<S> { /* private fields */ }Expand description
-m/--max-count. StandardBuilder has no max_matches, so the limit is
enforced by wrapping the printer’s sink and returning Ok(false) from
matched, which stops the search.
Implementations§
Source§impl<S: Sink> MaxCount<S>
impl<S: Sink> MaxCount<S>
pub fn new(inner: S, limit: Option<u64>) -> Self
Sourcepub fn saw_match(&self) -> bool
pub fn saw_match(&self) -> bool
Whether the searcher reported any match at all for this member.
This, and not the printer’s own summary, is the exit code’s source of
truth. See the note on matched below for why the difference matters.
Sourcepub fn count_suppressed_by_binary(&self) -> bool
pub fn count_suppressed_by_binary(&self) -> bool
Matched, then ran into binary data — the one combination that makes
SummarySink retract its count and print nothing.
Read from the searcher’s own SinkFinish, which is the same value
SummarySink::finish consults before squashing match_count to zero,
so the two can never disagree about whether a count was suppressed.
Only -c cares: -l prints the path, --json emits its records and
the default printer emits a binary warning of its own.
Trait Implementations§
Source§impl<S: Sink> Sink for MaxCount<S>
impl<S: Sink> Sink for MaxCount<S>
Source§type Error = <S as Sink>::Error
type Error = <S as Sink>::Error
Source§fn matched(&mut self, s: &Searcher, m: &SinkMatch<'_>) -> Result<bool, S::Error>
fn matched(&mut self, s: &Searcher, m: &SinkMatch<'_>) -> Result<bool, S::Error>
Source§fn context(
&mut self,
s: &Searcher,
c: &SinkContext<'_>,
) -> Result<bool, S::Error>
fn context( &mut self, s: &Searcher, c: &SinkContext<'_>, ) -> Result<bool, S::Error>
true. Read moreSource§fn context_break(&mut self, s: &Searcher) -> Result<bool, S::Error>
fn context_break(&mut self, s: &Searcher) -> Result<bool, S::Error>
true. Read more