Skip to main content

Searcher

Struct Searcher 

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

A query compiled for searching.

Implementations§

Source§

impl Searcher

Source

pub fn new(query: &SearchQuery) -> Result<Self, SearchError>

Source

pub fn new_raw(query: &SearchQuery) -> Result<Self, SearchError>

A searcher for text that keeps its CR LF and CR line endings (a file read as it is on disk): ^, $ and . treat \r as part of the line break, as they treat \n.

Source

pub fn options(&self) -> &SearchOptions

Source

pub fn find_next( &self, doc: &Document, from: ByteOffset, ) -> Option<Range<ByteOffset>>

The first match starting at or after from.

Source

pub fn find_prev( &self, doc: &Document, before: ByteOffset, ) -> Option<Range<ByteOffset>>

The last match starting before before. Searches backwards in growing windows, so a match near the caret is found quickly.

Source

pub fn matches<'a>( &'a self, doc: &'a Document, range: Range<ByteOffset>, ) -> impl Iterator<Item = Range<ByteOffset>> + 'a

The matches inside range, found as the iterator is advanced (so a caller can stop after enough of them).

Source

pub fn find_all( &self, doc: &Document, range: Range<ByteOffset>, ) -> Vec<Range<ByteOffset>>

All matches inside range.

Source

pub fn find_all_bytes(&self, hay: &[u8]) -> Vec<Range<usize>>

Every match in hay: text already in memory, such as a line on screen.

Source

pub fn matches_in<'a>( &'a self, src: &'a dyn ByteSource, range: Range<u64>, ) -> impl Iterator<Item = Range<u64>> + 'a

The matches inside range of src, found as the iterator is advanced (reading src a chunk at a time).

Source

pub fn find_next_in( &self, src: &dyn ByteSource, from: u64, ) -> Option<Range<u64>>

The first match in src starting at or after from.

Source

pub fn find_prev_in( &self, src: &dyn ByteSource, before: u64, ) -> Option<Range<u64>>

The last match in src starting before before, looked for in growing windows before it. A match may run at most 64 KB past before (the search stops there, so a document without matches after the caret is not read to its end).

Source

pub fn expand( &self, doc: &Document, m: Range<ByteOffset>, replacement: &str, ) -> String

The replacement text for the match at m.

Source

pub fn ranges( &self, doc: &Document, sels: &SelectionSet, ) -> Vec<Range<ByteOffset>>

The ranges to search: the non-empty selections with “in selection” on, otherwise the whole document.

Source

pub fn find_in( &self, doc: &Document, sels: &SelectionSet, ) -> Vec<Range<ByteOffset>>

Matches in the ranges ranges selects.

Source

pub fn next_from( &self, doc: &Document, sels: &SelectionSet, backward: bool, ) -> Option<Range<ByteOffset>>

The match to select for Find Next/Previous from the current primary selection, wrapping if enabled.

Source

pub fn replacement_for_selection( &self, doc: &Document, sels: &SelectionSet, replacement: &str, ) -> Option<(Range<ByteOffset>, String)>

If the primary selection is exactly a match, the range and its replacement text (for Replace).

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

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.