Struct grep_printer::Summary

source ·
pub struct Summary<W> { /* private fields */ }
Expand description

The summary printer, which emits aggregate results from a search.

Aggregate results generally correspond to file paths and/or the number of matches found.

A default printer can be created with either of the Summary::new or Summary::new_no_color constructors. However, there are a number of options that configure this printer’s output. Those options can be configured using SummaryBuilder.

This type is generic over W, which represents any implementation of the termcolor::WriteColor trait.

Implementations§

source§

impl<W: WriteColor> Summary<W>

source

pub fn new(wtr: W) -> Summary<W>

Return a summary printer with a default configuration that writes matches to the given writer.

The writer should be an implementation of termcolor::WriteColor and not just a bare implementation of io::Write. To use a normal io::Write implementation (simultaneously sacrificing colors), use the new_no_color constructor.

The default configuration uses the Count summary mode.

source§

impl<W: Write> Summary<NoColor<W>>

source

pub fn new_no_color(wtr: W) -> Summary<NoColor<W>>

Return a summary printer with a default configuration that writes matches to the given writer.

The writer can be any implementation of io::Write. With this constructor, the printer will never emit colors.

The default configuration uses the Count summary mode.

source§

impl<W: WriteColor> Summary<W>

source

pub fn sink<'s, M: Matcher>( &'s mut self, matcher: M, ) -> SummarySink<'static, 's, M, W>

Return an implementation of Sink for the summary printer.

This does not associate the printer with a file path, which means this implementation will never print a file path. If the output mode of this summary printer does not make sense without a file path (such as PathWithMatch or PathWithoutMatch), then any searches executed using this sink will immediately quit with an error.

source

pub fn sink_with_path<'p, 's, M, P>( &'s mut self, matcher: M, path: &'p P, ) -> SummarySink<'p, 's, M, W>
where M: Matcher, P: ?Sized + AsRef<Path>,

Return an implementation of Sink associated with a file path.

When the printer is associated with a path, then it may, depending on its configuration, print the path.

source§

impl<W> Summary<W>

source

pub fn has_written(&self) -> bool

Returns true if and only if this printer has written at least one byte to the underlying writer during any of the previous searches.

source

pub fn get_mut(&mut self) -> &mut W

Return a mutable reference to the underlying writer.

source

pub fn into_inner(self) -> W

Consume this printer and return back ownership of the underlying writer.

Trait Implementations§

source§

impl<W: Clone> Clone for Summary<W>

source§

fn clone(&self) -> Summary<W>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<W: Debug> Debug for Summary<W>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<W> !Freeze for Summary<W>

§

impl<W> !RefUnwindSafe for Summary<W>

§

impl<W> Send for Summary<W>
where W: Send,

§

impl<W> !Sync for Summary<W>

§

impl<W> Unpin for Summary<W>
where W: Unpin,

§

impl<W> UnwindSafe for Summary<W>
where W: 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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.