Struct rg::search::SearchWorker

source ·
pub struct SearchWorker<W> {
    config: Config,
    command_builder: CommandReaderBuilder,
    decomp_builder: DecompressionReaderBuilder,
    matcher: PatternMatcher,
    searcher: Searcher,
    printer: Printer<W>,
}
Expand description

A worker for executing searches.

It is intended for a single worker to execute many searches, and is generally intended to be used from a single thread. When searching using multiple threads, it is better to create a new worker for each thread.

Fields§

§config: Config§command_builder: CommandReaderBuilder§decomp_builder: DecompressionReaderBuilder§matcher: PatternMatcher§searcher: Searcher§printer: Printer<W>

Implementations§

source§

impl<W: WriteColor> SearchWorker<W>

source

pub fn search(&mut self, subject: &Subject) -> Result<SearchResult>

Execute a search over the given subject.

source

pub fn printer(&mut self) -> &mut Printer<W>

Return a mutable reference to the underlying printer.

source

pub fn print_stats( &mut self, total_duration: Duration, stats: &Stats ) -> Result<()>

Print the given statistics to the underlying writer in a way that is consistent with this searcher’s printer’s format.

While Stats contains a duration itself, this only corresponds to the time spent searching, where as total_duration should roughly approximate the lifespan of the ripgrep process itself.

source

fn should_decompress(&self, path: &Path) -> bool

Returns true if and only if the given file path should be decompressed before searching.

source

fn should_preprocess(&self, path: &Path) -> bool

Returns true if and only if the given file path should be run through the preprocessor.

source

fn search_preprocessor(&mut self, path: &Path) -> Result<SearchResult>

Search the given file path by first asking the preprocessor for the data to search instead of opening the path directly.

source

fn search_decompress(&mut self, path: &Path) -> Result<SearchResult>

Attempt to decompress the data at the given file path and search the result. If the given file path isn’t recognized as a compressed file, then search it without doing any decompression.

source

fn search_path(&mut self, path: &Path) -> Result<SearchResult>

Search the contents of the given file path.

source

fn search_reader<R: Read>( &mut self, path: &Path, rdr: &mut R ) -> Result<SearchResult>

Executes a search on the given reader, which may or may not correspond directly to the contents of the given file path. Instead, the reader may actually cause something else to be searched (for example, when a preprocessor is set or when decompression is enabled). In those cases, the file path is used for visual purposes only.

Generally speaking, this method should only be used when there is no other choice. Searching via search_path provides more opportunities for optimizations (such as memory maps).

Trait Implementations§

source§

impl<W: Debug> Debug for SearchWorker<W>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<W> !RefUnwindSafe for SearchWorker<W>

§

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

§

impl<W> !Sync for SearchWorker<W>

§

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

§

impl<W> UnwindSafe for SearchWorker<W>where W: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. 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 Twhere 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> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.