Skip to main content

SearchBuilder

Struct SearchBuilder 

Source
pub struct SearchBuilder { /* private fields */ }
Expand description

Fluent builder for rg-style search configuration.

use ripgrep_api::SearchBuilder;

let matches: Vec<_> = SearchBuilder::new("todo")
    .path(".")
    .glob("**/*.rs")
    .smart_case()
    .build()?
    .collect();

Implementations§

Source§

impl SearchBuilder

Source

pub fn new(pattern: impl Into<String>) -> Self

Source

pub fn path(self, path: impl AsRef<Path>) -> Self

Source

pub fn paths<I, P>(self, paths: I) -> Self
where I: IntoIterator<Item = P>, P: AsRef<Path>,

Source

pub fn build(self) -> Result<Search, SearchError>

Source

pub fn search_with<S: MatchSink>(self, sink: &mut S) -> Result<(), SearchError>

Source

pub fn for_each<F>(self, on_match: F) -> Result<(), SearchError>
where F: FnMut(&Match) -> bool,

Source

pub fn for_each_with_context<F, C>( self, on_match: F, on_context: C, ) -> Result<(), SearchError>
where F: FnMut(&Match) -> bool, C: FnMut(&ContextLine) -> bool,

Source

pub fn search_reader<R: Read>( self, reader: R, ) -> Result<Vec<Match>, SearchError>

Source

pub fn search_reader_named<R, P>( self, source: P, reader: R, ) -> Result<Vec<Match>, SearchError>
where R: Read, P: AsRef<Path>,

Source

pub fn search_slice(self, slice: &[u8]) -> Result<Vec<Match>, SearchError>

Source

pub fn search_slice_named<P>( self, source: P, slice: &[u8], ) -> Result<Vec<Match>, SearchError>
where P: AsRef<Path>,

Source

pub fn search_reader_with<R, S>( self, reader: R, sink: &mut S, ) -> Result<(), SearchError>
where R: Read, S: MatchSink,

Source

pub fn search_reader_with_named<R, P, S>( self, source: P, reader: R, sink: &mut S, ) -> Result<(), SearchError>
where R: Read, P: AsRef<Path>, S: MatchSink,

Source

pub fn search_slice_with<S>( self, slice: &[u8], sink: &mut S, ) -> Result<(), SearchError>
where S: MatchSink,

Source

pub fn search_slice_with_named<P, S>( self, source: P, slice: &[u8], sink: &mut S, ) -> Result<(), SearchError>
where P: AsRef<Path>, S: MatchSink,

Source

pub fn glob(self, pattern: impl Into<String>) -> Self

Source

pub fn type_(self, name: impl Into<String>) -> Self

Source

pub fn type_not(self, name: impl Into<String>) -> Self

Source

pub fn type_add(self, name: impl Into<String>, glob: impl Into<String>) -> Self

Source

pub fn types(self, types: Types) -> Self

Source

pub fn overrides(self, overrides: Override) -> Self

Source

pub fn max_depth(self, depth: usize) -> Self

Source

pub fn max_filesize(self, bytes: u64) -> Self

Source

pub fn hidden(self) -> Self

Source

pub fn follow(self) -> Self

Source

pub fn ignore(self, yes: bool) -> Self

Source

pub fn ignore_parent(self, yes: bool) -> Self

Source

pub fn ignore_files(self, yes: bool) -> Self

Source

pub fn ignore_vcs(self, yes: bool) -> Self

Source

pub fn smart_case(self) -> Self

Source

pub fn ignore_case(self) -> Self

Source

pub fn case_sensitive(self) -> Self

Source

pub fn fixed_strings(self) -> Self

Source

pub fn word(self) -> Self

Source

pub fn line_regexp(self) -> Self

Source

pub fn before_context(self, lines: usize) -> Self

Source

pub fn after_context(self, lines: usize) -> Self

Source

pub fn context(self, lines: usize) -> Self

Source

pub fn max_count(self, count: usize) -> Self

Source

pub fn binary_detection(self, yes: bool) -> Self

Source

pub fn threads(self, threads: usize) -> Self

Source

pub fn memory_map(self, choice: MmapChoice) -> Self

Source

pub fn heap_limit(self, bytes: usize) -> Self

Source

pub fn no_heap_limit(self) -> Self

Source

pub fn engine_default(self) -> Self

Source

pub fn count(self) -> Result<u64, SearchError>

Source

pub fn files_with_matches(self) -> Result<Vec<PathBuf>, SearchError>

Auto Trait Implementations§

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> 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

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 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.