[][src]Struct grep_printer::Standard

pub struct Standard<W> { /* fields omitted */ }

The standard printer, which implements grep-like formatting, including color support.

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

This type is generic over W, which represents any implementation of the termcolor::WriteColor trait. If colors are not desired, then the new_no_color constructor can be used, or, alternatively, the termcolor::NoColor adapter can be used to wrap any io::Write implementation without enabling any colors.

Implementations

impl<W: WriteColor> Standard<W>[src]

pub fn new(wtr: W) -> Standard<W>[src]

Return a standard 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.

impl<W: Write> Standard<NoColor<W>>[src]

pub fn new_no_color(wtr: W) -> Standard<NoColor<W>>[src]

Return a standard 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.

impl<W: WriteColor> Standard<W>[src]

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

Return an implementation of Sink for the standard printer.

This does not associate the printer with a file path, which means this implementation will never print a file path along with the matches.

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

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 along with the matches found.

impl<W> Standard<W>[src]

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

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

pub fn get_mut(&mut self) -> &mut W[src]

Return a mutable reference to the underlying writer.

pub fn into_inner(self) -> W[src]

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

Trait Implementations

impl<W: Debug> Debug for Standard<W>[src]

Auto Trait Implementations

impl<W> !RefUnwindSafe for Standard<W>

impl<W> Send for Standard<W> where
    W: Send

impl<W> !Sync for Standard<W>

impl<W> Unpin for Standard<W> where
    W: Unpin

impl<W> UnwindSafe for Standard<W> where
    W: UnwindSafe

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.