[][src]Struct grep_printer::StandardSink

pub struct StandardSink<'p, 's, M: Matcher, W: 's> { /* fields omitted */ }

An implementation of Sink associated with a matcher and an optional file path for the standard printer.

A Sink can be created via the Standard::sink or Standard::sink_with_path methods, depending on whether you want to include a file path in the printer's output.

Building a StandardSink is cheap, and callers should create a new one for each thing that is searched. After a search has completed, callers may query this sink for information such as whether a match occurred or whether binary data was found (and if so, the offset at which it occurred).

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 the Standard printer that this type borrows.
  • M refers to the type of matcher used by grep_searcher::Searcher that is reporting results to this sink.
  • W refers to the underlying writer that this printer is writing its output to.

Methods

impl<'p, 's, M: Matcher, W: WriteColor> StandardSink<'p, 's, M, W>[src]

pub fn has_match(&self) -> bool[src]

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 on this sink.

pub fn match_count(&self) -> u64[src]

Return the total number of matches reported to this sink.

This corresponds to the number of times Sink::matched is called on the previous search.

This is unaffected by the result of searches before the previous search on this sink.

pub fn binary_byte_offset(&self) -> Option<u64>[src]

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.

pub fn stats(&self) -> Option<&Stats>[src]

Return a reference to the stats produced by the printer for all searches executed on this sink.

This only returns stats if they were requested via the StandardBuilder configuration.

Trait Implementations

impl<'p, 's, M: Debug + Matcher, W: Debug + 's> Debug for StandardSink<'p, 's, M, W>[src]

impl<'p, 's, M: Matcher, W: WriteColor> Sink for StandardSink<'p, 's, M, W>[src]

type Error = Error

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

Auto Trait Implementations

impl<'p, 's, M, W> Send for StandardSink<'p, 's, M, W> where
    M: Send,
    W: Send,
    <M as Matcher>::Captures: Send

impl<'p, 's, M, W> !Sync for StandardSink<'p, 's, M, W>

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.