Skip to main content

SearchQuery

Struct SearchQuery 

Source
pub struct SearchQuery<'a> { /* private fields */ }
Expand description

A composable query for filtering notes in a vault.

§Filter semantics

Implementations§

Source§

impl SearchQuery<'static>

Source

pub fn new(root: impl AsRef<Path>) -> Self

Source

pub fn with_loaded_notes<'a>( self, notes: &'a HashMap<PathBuf, Note>, ) -> SearchQuery<'a>

Provide in-memory notes to use instead of their on-disk counterparts.

Each note’s note.path is matched against the vault’s note paths on disk. Notes whose paths exist on disk shadow the disk version; notes with no on-disk counterpart are included as additional candidates. In-memory notes are assumed to have content populated whenever content filters (e.g. and_content_contains) are used.

Source§

impl<'a> SearchQuery<'a>

Source

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

Note path must match this glob pattern (matched against the note’s path relative to the vault root).

Source

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

Note path could match this glob pattern (matched against the note’s path relative to the vault root).

Source

pub fn and_has_id(self, id: impl Into<String>) -> Self

Note must have this ID (case-sensitive by default).

Source

pub fn or_has_id(self, id: impl Into<String>) -> Self

Note could have this ID (case-sensitive by default).

Source

pub fn and_has_tag(self, tag: impl Into<String>) -> Self

Note must have this tag (case-insensitive by default).

Source

pub fn or_has_tag(self, tag: impl Into<String>) -> Self

Note could have this tag (case-insensitive by default).

Source

pub fn and_title_contains(self, s: impl Into<String>) -> Self

Must title must contain this substring (smart case-sensitive by default).

Source

pub fn or_title_contains(self, s: impl Into<String>) -> Self

Must title could contain this substring (smart case-sensitive by default).

Source

pub fn and_has_alias(self, alias: impl Into<String>) -> Self

Note must have this alias (smart case-sensitive by default).

Source

pub fn or_has_alias(self, alias: impl Into<String>) -> Self

Note could have this alias (smart case-sensitive by default).

Source

pub fn and_alias_contains(self, s: impl Into<String>) -> Self

Substring must match against any of the note’s aliases (smart case-sensitive by default).

Source

pub fn or_alias_contains(self, s: impl Into<String>) -> Self

Substring could match against any of the note’s aliases (smart case-sensitive by default).

Source

pub fn and_content_contains(self, s: impl Into<String>) -> Self

Note body must contain this string (smart case-sensitive by default).

Source

pub fn or_content_contains(self, s: impl Into<String>) -> Self

Note body could contain this string (smart case-sensitive by default).

Source

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

Regex body must match this pattern (smart case-sensitive by default).

Source

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

Regex body could match this pattern (smart case-sensitive by default).

Has a link to this note

May link to this note

Source

pub fn case_sensitive(self) -> Self

Execute the search case-sensitively.

Source

pub fn ignore_case(self) -> Self

Execute the search case-insensitively.

Source

pub fn smart_case(self) -> Self

Execute the search with smart case sensitivity: case-sensitive if the query contains any uppercase letters, otherwise case-insensitive.

Source

pub fn include_inline_tags(self) -> Self

Source

pub fn sort_by(self, sort_order: SortOrder) -> Self

Source

pub fn execute(self) -> Result<Vec<Result<Note, NoteError>>, SearchError>

Execute the query, returning matching notes.

Returns Err if any glob or regex pattern is invalid. Each inner Err represents an I/O failure loading a specific note.

Auto Trait Implementations§

§

impl<'a> Freeze for SearchQuery<'a>

§

impl<'a> RefUnwindSafe for SearchQuery<'a>

§

impl<'a> Send for SearchQuery<'a>

§

impl<'a> Sync for SearchQuery<'a>

§

impl<'a> Unpin for SearchQuery<'a>

§

impl<'a> UnsafeUnpin for SearchQuery<'a>

§

impl<'a> UnwindSafe for SearchQuery<'a>

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.