Struct QueryBuilder

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

A builder for constructing Anki search queries

This builder provides a fluent interface for creating properly escaped and formatted Anki search queries. It helps prevent syntax errors and ensures proper escaping of special characters.

Implementations§

Source§

impl QueryBuilder

Source

pub fn new() -> Self

Creates a new, empty query builder

Source

pub fn text<S: AsRef<str>>(self, text: S) -> Self

Adds free text to search for across all fields

Special characters are automatically escaped.

Source

pub fn field<S: AsRef<str>>(self, field_name: S) -> FieldQueryBuilder

Specifies a field to search in

This must be followed by one of the field content methods like contains.

Source

pub fn in_field(self, field: &Field) -> FieldQueryBuilder

Specifies a field to search in using a Field reference

This must be followed by one of the field content methods like contains.

Source

pub fn in_field_ref(self, field_ref: FieldRef<'_>) -> FieldQueryBuilder

Specifies a field to search in using a FieldRef

This ensures the field actually exists in a model. This must be followed by one of the field content methods like contains.

Source

pub fn has_tag<S: AsRef<str>>(self, tag: S) -> Self

Searches for cards with a specific tag

Source

pub fn in_deck<S: AsRef<str>>(self, deck: S) -> Self

Searches for cards in a specific deck

Source

pub fn in_deck_obj(self, deck: &Deck) -> Self

Searches for cards in the specified deck object

Source

pub fn in_state(self, state: CardState) -> Self

Searches for cards in a specific card state

Source

pub fn not(self) -> Self

Negates the next condition

Source

pub fn and(self) -> Self

Combines with the next condition using AND (implicit in Anki)

Source

pub fn or(self) -> Self

Combines with the next condition using OR

Source

pub fn has_flag(self, flag: Flag) -> Self

Searches for cards with a specific flag

Source

pub fn interval_at_least(self, days: u32) -> Self

Searches for cards with an interval greater than or equal to the specified days

Source

pub fn due_in(self, days: i32) -> Self

Searches for cards due in the specified number of days

Source

pub fn reps_less_than(self, count: u32) -> Self

Searches for cards with fewer than the specified number of repetitions

Source

pub fn added_in_last_n_days(self, days: u32) -> Self

Searches for cards added within the last n days

Source

pub fn rated_today(self) -> Self

Searches for cards rated today

Source

pub fn rated_in_last_n_days(self, days: u32) -> Self

Searches for cards rated within the last n days

Source

pub fn build(self) -> Query

Builds the final query

Source§

impl QueryBuilder

Convenience functions for common queries

Source

pub fn deck<S: AsRef<str>>(deck: S) -> Self

Creates a query that searches for cards in the specified deck

Source

pub fn tag<S: AsRef<str>>(tag: S) -> Self

Creates a query that searches for cards with the specified tag

Source

pub fn state(state: CardState) -> Self

Creates a query that searches for cards in the specified state

Source

pub fn flag(flag: Flag) -> Self

Creates a query that searches for cards with the specified flag

Trait Implementations§

Source§

impl Clone for QueryBuilder

Source§

fn clone(&self) -> QueryBuilder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for QueryBuilder

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for QueryBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.