pub struct Field<T, V> { /* private fields */ }Expand description
Field accessor.
Carries both the column / serde-key name (used by downstream
SQL-emitting consumers like djogi) and the in-memory extractor used
by sassi’s predicate evaluator. The two halves let the same
Field<T, V> value participate in a SQL WHERE emit on a backend
AND a Rust-side evaluate() walk on a frontend, without diverging.
Internal storage is pub(crate) to keep the (name, extractor) pair
stable post-construction. Use Field::name and Field::extract
accessors instead of direct field access.
§Example
use sassi::Field;
struct User { id: i64, age: u32 }
// Normally generated by `#[derive(Cacheable)]`; shown here for
// documentation:
let age_field: Field<User, u32> = Field::new("age", |u| &u.age);
let alice = User { id: 1, age: 30 };
assert_eq!(*age_field.extract(&alice), 30);
assert_eq!(age_field.name(), "age");Implementations§
Source§impl<T, V> Field<T, V>
impl<T, V> Field<T, V>
Source§impl<T: 'static, V: PartialEq + Send + Sync + 'static> Field<T, V>
impl<T: 'static, V: PartialEq + Send + Sync + 'static> Field<T, V>
Sourcepub fn eq(&self, val: V) -> BasicPredicate<T>
pub fn eq(&self, val: V) -> BasicPredicate<T>
field == value.
Sourcepub fn neq(&self, val: V) -> BasicPredicate<T>
pub fn neq(&self, val: V) -> BasicPredicate<T>
field != value.
Source§impl<T: 'static, V: PartialOrd + Send + Sync + 'static> Field<T, V>
impl<T: 'static, V: PartialOrd + Send + Sync + 'static> Field<T, V>
Sourcepub fn gt(&self, val: V) -> BasicPredicate<T>
pub fn gt(&self, val: V) -> BasicPredicate<T>
field > value.
Sourcepub fn gte(&self, val: V) -> BasicPredicate<T>
pub fn gte(&self, val: V) -> BasicPredicate<T>
field >= value.
Sourcepub fn lt(&self, val: V) -> BasicPredicate<T>
pub fn lt(&self, val: V) -> BasicPredicate<T>
field < value.
Sourcepub fn lte(&self, val: V) -> BasicPredicate<T>
pub fn lte(&self, val: V) -> BasicPredicate<T>
field <= value.
Sourcepub fn between(&self, low: V, high: V) -> BasicPredicate<T>
pub fn between(&self, low: V, high: V) -> BasicPredicate<T>
low <= field <= high (inclusive on both ends).
Operand value layout: Arc<(V, V)> carrying (low, high).
Source§impl<T: 'static, V: PartialEq + Send + Sync + 'static> Field<T, V>
impl<T: 'static, V: PartialEq + Send + Sync + 'static> Field<T, V>
Sourcepub fn in_(&self, vals: Vec<V>) -> BasicPredicate<T>
pub fn in_(&self, vals: Vec<V>) -> BasicPredicate<T>
field IN (values…). Operand value layout: Arc<Vec<V>>.
Sourcepub fn not_in(&self, vals: Vec<V>) -> BasicPredicate<T>
pub fn not_in(&self, vals: Vec<V>) -> BasicPredicate<T>
field NOT IN (values…). Operand value layout: Arc<Vec<V>>.
Source§impl<T: 'static, U: Send + Sync + 'static> Field<T, Option<U>>
impl<T: 'static, U: Send + Sync + 'static> Field<T, Option<U>>
Sourcepub fn is_null(&self) -> BasicPredicate<T>
pub fn is_null(&self) -> BasicPredicate<T>
field IS NULL. Only meaningful on Option<U> fields.
Operand value layout: Arc<()> (no operand).
Sourcepub fn is_not_null(&self) -> BasicPredicate<T>
pub fn is_not_null(&self) -> BasicPredicate<T>
field IS NOT NULL. Only meaningful on Option<U> fields.
Operand value layout: Arc<()> (no operand).
Source§impl<T, V> Field<T, Option<V>>
impl<T, V> Field<T, Option<V>>
Sourcepub fn some(&self) -> PresentField<T, V>
pub fn some(&self) -> PresentField<T, V>
Compare only the present Some(V) value.
Source§impl<T: 'static> Field<T, String>
impl<T: 'static> Field<T, String>
Sourcepub fn contains(&self, needle: &str) -> BasicPredicate<T>
pub fn contains(&self, needle: &str) -> BasicPredicate<T>
Case-sensitive substring match: field contains the needle.
Operand value layout: Arc<String>.
Sourcepub fn icontains(&self, needle: &str) -> BasicPredicate<T>
pub fn icontains(&self, needle: &str) -> BasicPredicate<T>
Case-insensitive substring match using ASCII-only folding.
Operand value layout: Arc<String>
— original (non-lowered) needle for inspection.
Sourcepub fn starts_with(&self, prefix: &str) -> BasicPredicate<T>
pub fn starts_with(&self, prefix: &str) -> BasicPredicate<T>
field starts with the prefix (case-sensitive). Operand value
layout: Arc<String>.
Sourcepub fn istarts_with(&self, prefix: &str) -> BasicPredicate<T>
pub fn istarts_with(&self, prefix: &str) -> BasicPredicate<T>
field starts with the prefix (case-insensitive).
Operand value layout: Arc<String> — original (non-lowered).
Sourcepub fn ends_with(&self, suffix: &str) -> BasicPredicate<T>
pub fn ends_with(&self, suffix: &str) -> BasicPredicate<T>
field ends with the suffix (case-sensitive). Operand value
layout: Arc<String>.
Sourcepub fn iends_with(&self, suffix: &str) -> BasicPredicate<T>
pub fn iends_with(&self, suffix: &str) -> BasicPredicate<T>
field ends with the suffix (case-insensitive).
Operand value layout: Arc<String> — original (non-lowered).
Sourcepub fn iexact(&self, val: &str) -> BasicPredicate<T>
pub fn iexact(&self, val: &str) -> BasicPredicate<T>
field == value using ASCII-only case folding.
Operand value layout: Arc<String> — original.