Struct grep_searcher::Searcher[][src]

pub struct Searcher { /* fields omitted */ }

A searcher executes searches over a haystack and writes results to a caller provided sink.

Matches are detected via implementations of the Matcher trait, which must be provided by the caller when executing a search.

When possible, a searcher should be reused.

Methods

impl Searcher
[src]

Create a new searcher with a default configuration.

To configure the searcher (e.g., invert matching, enable memory maps, enable contexts, etc.), use the SearcherBuilder.

Execute a search over the file with the given path and write the results to the given sink.

If memory maps are enabled and the searcher heuristically believes memory maps will help the search run faster, then this will use memory maps. For this reason, callers should prefer using this method or search_file over the more generic search_reader when possible.

Execute a search over a file and write the results to the given sink.

If memory maps are enabled and the searcher heuristically believes memory maps will help the search run faster, then this will use memory maps. For this reason, callers should prefer using this method or search_path over the more generic search_reader when possible.

Execute a search over any implementation of io::Read and write the results to the given sink.

When possible, this implementation will search the reader incrementally without reading it into memory. In some cases---for example, if multi line search is enabled---an incremental search isn't possible and the given reader is consumed completely and placed on the heap before searching begins. For this reason, when multi line search is enabled, one should try to use higher level APIs (e.g., searching by file or file path) so that memory maps can be used if they are available and enabled.

Execute a search over the given slice and write the results to the given sink.

impl Searcher
[src]

The following methods permit querying the configuration of a searcher. These can be useful in generic implementations of Sink, where the output may be tailored based on how the searcher is configured.

Returns the line terminator used by this searcher.

Returns true if and only if this searcher is configured to invert its search results. That is, matching lines are lines that do not match the searcher's matcher.

Returns true if and only if this searcher is configured to count line numbers.

Returns true if and only if this searcher is configured to perform multi line search.

Returns true if and only if this searcher will choose a multi-line strategy given the provided matcher.

This may diverge from the result of multi_line in cases where the searcher has been configured to execute a search that can report matches over multiple lines, but where the matcher guarantees that it will never produce a match over multiple lines.

Returns the number of "after" context lines to report. When context reporting is not enabled, this returns 0.

Returns the number of "before" context lines to report. When context reporting is not enabled, this returns 0.

Returns true if and only if the searcher has "passthru" mode enabled.

Trait Implementations

impl Clone for Searcher
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for Searcher
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl Send for Searcher

impl !Sync for Searcher