Skip to main content

LambdaWrapper

Struct LambdaWrapper 

Source
pub struct LambdaWrapper<T: GetFields> { /* private fields */ }
Expand description

Lambda wrapper for compile-time safe column references.

This wrapper uses struct field accessor functions instead of string column names, providing compile-time safety for column references.

Implementations§

Source§

impl<T: GetFields> LambdaWrapper<T>

Source

pub fn new() -> Self

Create a new, empty lambda wrapper.

§Example
let wrapper = LambdaWrapper::<User>::new();
Source

pub fn from_wrapper(wrapper: Wrapper) -> Self

Create a lambda wrapper from an existing Wrapper.

This allows wrapping an already-configured Wrapper to add lambda-style type-safe conditions on top.

§Parameters
  • wrapper: The existing Wrapper to wrap.
Source

pub fn into_wrapper(self) -> Wrapper

Consume the lambda wrapper and return the underlying Wrapper.

Useful when you need to pass the built wrapper to a query executor.

Source

pub fn wrapper(&self) -> &Wrapper

Get a reference to the underlying Wrapper.

Useful for inspecting the current state of the query without consuming the lambda wrapper.

Source

pub fn eq<V: IntoAkitaValue>(self, field: fn(&T) -> String, value: V) -> Self

Add an equals (=) condition using a field accessor.

§Parameters
  • field: A function that extracts the column name from the entity struct.
  • value: The value to compare against.
§Example
let wrapper = LambdaWrapper::<User>::new()
    .eq(User::name, "Alice");
Source

pub fn ne<V: IntoAkitaValue>(self, field: fn(&T) -> String, value: V) -> Self

Add a not equals (!=) condition using a field accessor.

§Parameters
  • field: A function that extracts the column name from the entity struct.
  • value: The value to compare against.
Source

pub fn gt<V: IntoAkitaValue>(self, field: fn(&T) -> String, value: V) -> Self

Add a greater than (>) condition using a field accessor.

§Parameters
  • field: A function that extracts the column name from the entity struct.
  • value: The value to compare against.
Source

pub fn ge<V: IntoAkitaValue>(self, field: fn(&T) -> String, value: V) -> Self

Add a greater than or equals (>=) condition using a field accessor.

§Parameters
  • field: A function that extracts the column name from the entity struct.
  • value: The value to compare against.
Source

pub fn lt<V: IntoAkitaValue>(self, field: fn(&T) -> String, value: V) -> Self

Add a less than (<) condition using a field accessor.

§Parameters
  • field: A function that extracts the column name from the entity struct.
  • value: The value to compare against.
Source

pub fn le<V: IntoAkitaValue>(self, field: fn(&T) -> String, value: V) -> Self

Add a less than or equals (<=) condition using a field accessor.

§Parameters
  • field: A function that extracts the column name from the entity struct.
  • value: The value to compare against.
Source

pub fn like<V: IntoAkitaValue>(self, field: fn(&T) -> String, value: V) -> Self

Add a LIKE condition using a field accessor.

§Parameters
  • field: A function that extracts the column name from the entity struct.
  • value: The pattern to match against (supports % and _ wildcards).
Source

pub fn not_like<V: IntoAkitaValue>( self, field: fn(&T) -> String, value: V, ) -> Self

Add a NOT LIKE condition using a field accessor.

§Parameters
  • field: A function that extracts the column name from the entity struct.
  • value: The pattern to exclude (supports % and _ wildcards).
Source

pub fn is_null(self, field: fn(&T) -> String) -> Self

Add an IS NULL condition using a field accessor.

§Parameters
  • field: A function that extracts the column name from the entity struct.
Source

pub fn is_not_null(self, field: fn(&T) -> String) -> Self

Add an IS NOT NULL condition using a field accessor.

§Parameters
  • field: A function that extracts the column name from the entity struct.
Source

pub fn in<V: IntoAkitaValue, I: IntoIterator<Item = V>>( self, field: fn(&T) -> String, values: I, ) -> Self

Add an IN condition using a field accessor.

§Parameters
  • field: A function that extracts the column name from the entity struct.
  • values: An iterable of values to match against.
Source

pub fn not_in<V: IntoAkitaValue, I: IntoIterator<Item = V>>( self, field: fn(&T) -> String, values: I, ) -> Self

Add a NOT IN condition using a field accessor.

§Parameters
  • field: A function that extracts the column name from the entity struct.
  • values: An iterable of values to exclude.
Source

pub fn between<V: IntoAkitaValue>( self, field: fn(&T) -> String, start: V, end: V, ) -> Self

Add a BETWEEN condition using a field accessor.

§Parameters
  • field: A function that extracts the column name from the entity struct.
  • start: The lower bound value (inclusive).
  • end: The upper bound value (inclusive).
Source

pub fn not_between<V: IntoAkitaValue>( self, field: fn(&T) -> String, start: V, end: V, ) -> Self

Add a NOT BETWEEN condition using a field accessor.

§Parameters
  • field: A function that extracts the column name from the entity struct.
  • start: The lower bound value (inclusive).
  • end: The upper bound value (inclusive).
Source

pub fn and<F>(self, func: F) -> Self
where F: FnOnce(LambdaWrapper<T>) -> LambdaWrapper<T>,

Add an AND group of conditions.

The closure receives a fresh LambdaWrapper<T> and should return it with the desired conditions applied. The resulting conditions are wrapped in parentheses and joined with AND.

§Parameters
  • func: A closure that configures the inner lambda wrapper.
Source

pub fn or<F>(self, func: F) -> Self
where F: FnOnce(LambdaWrapper<T>) -> LambdaWrapper<T>,

Add an OR group of conditions.

The closure receives a fresh LambdaWrapper<T> and should return it with the desired conditions applied. The resulting conditions are wrapped in parentheses and joined with OR.

§Parameters
  • func: A closure that configures the inner lambda wrapper.
Source

pub fn or_direct(self) -> Self

Add a direct OR separator between the previous and next condition.

Unlike or(), this does not create a parenthesized group. It simply inserts OR at the current position in the WHERE clause.

Source

pub fn order_by_asc(self, field: fn(&T) -> String) -> Self

Add an ORDER BY ASC clause using a field accessor.

§Parameters
  • field: A function that extracts the column name to sort by.
Source

pub fn order_by_desc(self, field: fn(&T) -> String) -> Self

Add an ORDER BY DESC clause using a field accessor.

§Parameters
  • field: A function that extracts the column name to sort by.
Source

pub fn limit(self, limit: u64) -> Self

Set the maximum number of rows to return.

§Parameters
  • limit: The maximum number of rows.
Source

pub fn offset(self, offset: u64) -> Self

Set the number of rows to skip before returning results.

§Parameters
  • offset: The number of rows to skip.
Source

pub fn page(self, page: u64, size: u64) -> Self

Set pagination by page number and page size.

This is a convenience method that computes the appropriate LIMIT and OFFSET from the given page number and size.

§Parameters
  • page: The 1-based page number.
  • size: The number of rows per page.
Source

pub fn when(self, condition: bool) -> Self

Conditionally apply the next condition.

If condition is true, the next chained condition is applied normally. If false, the next condition is silently skipped.

§Parameters
  • condition: Whether the next condition should be applied.
Source

pub fn unless(self, condition: bool) -> Self

Conditionally skip the next condition.

This is the inverse of when(). If condition is true, the next condition is skipped. If false, it is applied normally.

§Parameters
  • condition: Whether the next condition should be skipped.

Auto Trait Implementations§

§

impl<T> Freeze for LambdaWrapper<T>

§

impl<T> RefUnwindSafe for LambdaWrapper<T>
where T: RefUnwindSafe,

§

impl<T> Send for LambdaWrapper<T>
where T: Send,

§

impl<T> Sync for LambdaWrapper<T>
where T: Sync,

§

impl<T> Unpin for LambdaWrapper<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for LambdaWrapper<T>

§

impl<T> UnwindSafe for LambdaWrapper<T>
where T: UnwindSafe,

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

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

Source§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
Source§

impl<T> From<T> for T

Source§

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

Source§

type Metadata = ()

The type for metadata in pointers and references to Self.
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.
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