FluentFilterBuilder

Struct FluentFilterBuilder 

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

A fluent builder for constructing filters with a convenient API.

This builder collects conditions and can produce either an AND or OR filter.

§Examples

use prax_query::filter::Filter;

// Build an AND filter
let filter = Filter::builder()
    .eq("active", true)
    .gt("score", 100)
    .contains("email", "@example.com")
    .build_and();

// Build an OR filter with capacity hint
let filter = Filter::builder()
    .with_capacity(3)
    .eq("role", "admin")
    .eq("role", "moderator")
    .eq("role", "owner")
    .build_or();

Implementations§

Source§

impl FluentFilterBuilder

Source

pub fn new() -> Self

Create a new fluent builder.

Source

pub fn with_capacity(self, capacity: usize) -> Self

Set the capacity hint for the internal vector.

Source

pub fn eq<F, V>(self, field: F, value: V) -> Self
where F: Into<FieldName>, V: Into<FilterValue>,

Add an equals filter.

Source

pub fn ne<F, V>(self, field: F, value: V) -> Self
where F: Into<FieldName>, V: Into<FilterValue>,

Add a not equals filter.

Source

pub fn lt<F, V>(self, field: F, value: V) -> Self
where F: Into<FieldName>, V: Into<FilterValue>,

Add a less than filter.

Source

pub fn lte<F, V>(self, field: F, value: V) -> Self
where F: Into<FieldName>, V: Into<FilterValue>,

Add a less than or equal filter.

Source

pub fn gt<F, V>(self, field: F, value: V) -> Self
where F: Into<FieldName>, V: Into<FilterValue>,

Add a greater than filter.

Source

pub fn gte<F, V>(self, field: F, value: V) -> Self
where F: Into<FieldName>, V: Into<FilterValue>,

Add a greater than or equal filter.

Source

pub fn is_in<F, I, V>(self, field: F, values: I) -> Self
where F: Into<FieldName>, I: IntoIterator<Item = V>, V: Into<FilterValue>,

Add an IN filter.

Source

pub fn not_in<F, I, V>(self, field: F, values: I) -> Self
where F: Into<FieldName>, I: IntoIterator<Item = V>, V: Into<FilterValue>,

Add a NOT IN filter.

Source

pub fn contains<F, V>(self, field: F, value: V) -> Self
where F: Into<FieldName>, V: Into<FilterValue>,

Add a contains filter (LIKE %value%).

Source

pub fn starts_with<F, V>(self, field: F, value: V) -> Self
where F: Into<FieldName>, V: Into<FilterValue>,

Add a starts with filter (LIKE value%).

Source

pub fn ends_with<F, V>(self, field: F, value: V) -> Self
where F: Into<FieldName>, V: Into<FilterValue>,

Add an ends with filter (LIKE %value).

Source

pub fn is_null<F>(self, field: F) -> Self
where F: Into<FieldName>,

Add an IS NULL filter.

Source

pub fn is_not_null<F>(self, field: F) -> Self
where F: Into<FieldName>,

Add an IS NOT NULL filter.

Source

pub fn filter(self, filter: Filter) -> Self

Add a raw filter directly.

Source

pub fn filter_if(self, condition: bool, filter: Filter) -> Self

Add a filter conditionally.

Source

pub fn filter_if_some<F>(self, opt: Option<F>) -> Self
where F: Into<Filter>,

Add a filter conditionally if the option is Some.

Source

pub fn build_and(self) -> Filter

Build an AND filter from all collected conditions.

Source

pub fn build_or(self) -> Filter

Build an OR filter from all collected conditions.

Source

pub fn len(&self) -> usize

Get the current number of filters.

Source

pub fn is_empty(&self) -> bool

Check if the builder is empty.

Trait Implementations§

Source§

impl Clone for FluentFilterBuilder

Source§

fn clone(&self) -> FluentFilterBuilder

Returns a duplicate of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for FluentFilterBuilder

Source§

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

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

impl Default for FluentFilterBuilder

Source§

fn default() -> Self

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

Auto Trait Implementations§

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

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
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
§

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

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

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

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

Uses borrowed data to replace owned data, usually by cloning. Read more
§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

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

§

type Error = <U as TryFrom<T>>::Error

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more