Skip to main content

FieldRef

Struct FieldRef 

Source
pub struct FieldRef<S: Schema, T> { /* private fields */ }
Expand description

Type-safe field reference holding schema and Rust type information.

This struct binds a field to both its schema and expected Rust type, enabling compile-time type checking for filter operations.

NOTE: FieldRef equality and hashing are based solely on the underlying schema field. The generic type parameter T is a phantom type used only for compile-time validation of operations and is not part of the field identity.

§Type Parameters

  • S - The schema type implementing Schema
  • T - The Rust type this field represents (e.g., String, uuid::Uuid)

Implementations§

Source§

impl<S: Schema, T> FieldRef<S, T>

Source

pub const fn new(field: S::Field) -> Self

Create a new typed field reference.

§Example
const NAME: FieldRef<UserSchema, String> = FieldRef::new(UserField::Name);
Source

pub fn name(&self) -> &'static str

Get the field name as a string.

Source§

impl<S: Schema, T> FieldRef<S, T>

Comparison operations for any field type.

Source

pub fn eq<V: IntoODataValue>(self, value: V) -> Expr

Create an equality comparison: field eq value

§Example
let filter = ID.eq(user_id);
Source

pub fn ne<V: IntoODataValue>(self, value: V) -> Expr

Create a not-equal comparison: field ne value

Source

pub fn gt<V: IntoODataValue>(self, value: V) -> Expr

Create a greater-than comparison: field gt value

Source

pub fn ge<V: IntoODataValue>(self, value: V) -> Expr

Create a greater-than-or-equal comparison: field ge value

Source

pub fn lt<V: IntoODataValue>(self, value: V) -> Expr

Create a less-than comparison: field lt value

Source

pub fn le<V: IntoODataValue>(self, value: V) -> Expr

Create a less-than-or-equal comparison: field le value

Source

pub fn is_null(self) -> Expr

Create a null check: field eq null

§Example
let filter = OPTIONAL_FIELD.is_null();
Source

pub fn is_not_null(self) -> Expr

Create a not-null check: field ne null

§Example
let filter = OPTIONAL_FIELD.is_not_null();
Source§

impl<S: Schema> FieldRef<S, String>

String-specific operations (only available for String fields).

Source

pub fn contains(self, substring: &str) -> Expr

Create a contains function call: contains(field, 'value')

§Example
let filter = NAME.contains("john");
Source

pub fn startswith(self, prefix: &str) -> Expr

Create a startswith function call: startswith(field, 'prefix')

§Example
let filter = NAME.startswith("Dr");
Source

pub fn endswith(self, suffix: &str) -> Expr

Create an endswith function call: endswith(field, 'suffix')

§Example
let filter = EMAIL.endswith("@example.com");

Trait Implementations§

Source§

impl<S: Schema, T> Clone for FieldRef<S, T>

Source§

fn clone(&self) -> Self

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<S: Schema, T> Debug for FieldRef<S, T>

Source§

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

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

impl<S: Schema, T> Hash for FieldRef<S, T>
where S::Field: Hash,

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<S: Schema, T> PartialEq for FieldRef<S, T>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S: Schema, T> Copy for FieldRef<S, T>

Source§

impl<S: Schema, T> Eq for FieldRef<S, T>

Auto Trait Implementations§

§

impl<S, T> Freeze for FieldRef<S, T>
where <S as Schema>::Field: Freeze,

§

impl<S, T> RefUnwindSafe for FieldRef<S, T>

§

impl<S, T> Send for FieldRef<S, T>
where <S as Schema>::Field: Send, S: Send, T: Send,

§

impl<S, T> Sync for FieldRef<S, T>
where <S as Schema>::Field: Sync, S: Sync, T: Sync,

§

impl<S, T> Unpin for FieldRef<S, T>
where <S as Schema>::Field: Unpin, S: Unpin, T: Unpin,

§

impl<S, T> UnsafeUnpin for FieldRef<S, T>
where <S as Schema>::Field: UnsafeUnpin,

§

impl<S, T> UnwindSafe for FieldRef<S, T>
where <S as Schema>::Field: UnwindSafe, S: UnwindSafe, 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> 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> Same for T

Source§

type Output = T

Should always be Self
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.