Skip to main content

MaxCount

Struct MaxCount 

Source
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>

Source

pub fn new(inner: S, limit: Option<u64>) -> Self

Source

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.

Source

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>

Source§

type Error = <S as Sink>::Error

The type of an error that should be reported by a searcher. Read more
Source§

fn matched(&mut self, s: &Searcher, m: &SinkMatch<'_>) -> Result<bool, S::Error>

This method is called whenever a match is found. Read more
Source§

fn context( &mut self, s: &Searcher, c: &SinkContext<'_>, ) -> Result<bool, S::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 more
Source§

fn context_break(&mut self, s: &Searcher) -> Result<bool, S::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 more
Source§

fn binary_data(&mut self, s: &Searcher, off: u64) -> Result<bool, S::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
Source§

fn begin(&mut self, s: &Searcher) -> Result<bool, S::Error>

This method is called when a search has begun, before any search is executed. By default, this does nothing. Read more
Source§

fn finish(&mut self, s: &Searcher, f: &SinkFinish) -> Result<(), S::Error>

This method is called when a search has completed. By default, this does nothing. Read more

Auto Trait Implementations§

§

impl<S> Freeze for MaxCount<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for MaxCount<S>
where S: RefUnwindSafe,

§

impl<S> Send for MaxCount<S>
where S: Send,

§

impl<S> Sync for MaxCount<S>
where S: Sync,

§

impl<S> Unpin for MaxCount<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for MaxCount<S>
where S: UnsafeUnpin,

§

impl<S> UnwindSafe for MaxCount<S>
where S: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.