Struct grep_searcher::sinks::Lossy[][src]

pub struct Lossy<F>(pub F)
where
    F: FnMut(u64, &str) -> Result<bool, Error>
;

A sink that provides line numbers and matches as (lossily converted) strings while ignoring everything else.

This is like UTF8, except that if a match contains invalid UTF-8, then it will be lossily converted to valid UTF-8 by substituting invalid UTF-8 with Unicode replacement characters.

This implementation will return an error on the first match if the searcher was not configured to count lines.

The closure accepts two parameters: a line number and a UTF-8 string containing the matched data. The closure returns a Result<bool, io::Error>. If the bool is false, then the search stops immediately. Otherwise, searching continues.

If multi line mode was enabled, the line number refers to the line number of the first line in the match.

Trait Implementations

impl<F: Clone> Clone for Lossy<F> where
    F: FnMut(u64, &str) -> Result<bool, Error>, 
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<F: Debug> Debug for Lossy<F> where
    F: FnMut(u64, &str) -> Result<bool, Error>, 
[src]

Formats the value using the given formatter. Read more

impl<F> Sink for Lossy<F> where
    F: FnMut(u64, &str) -> Result<bool, Error>, 
[src]

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

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

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

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

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

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

Auto Trait Implementations

impl<F> Send for Lossy<F> where
    F: Send

impl<F> Sync for Lossy<F> where
    F: Sync