Skip to main content

Col

Struct Col 

Source
pub struct Col<V: 'static> {
    pub column: &'static str,
    pub field: &'static str,
    pub owner: &'static str,
    /* private fields */
}
Expand description

A typed column reference, what Trip::name() returns (the derive emits one inherent fn per persisted field). It knows the column’s name and its stored encoding, so a predicate built from it compares in the column’s stored language whatever codec the field uses.

Fields§

§column: &'static str§field: &'static str

The struct field this column stores. The change log speaks field names and the SQL speaks column names; they differ under #[model(column = "…")], and a relation is wired by field, so a predicate that crosses one needs both.

§owner: &'static str

The table this column belongs to, which disambiguates a relation when two models happen to name a field alike.

Implementations§

Source§

impl<V> Col<V>

Source

pub const fn new( column: &'static str, field: &'static str, owner: &'static str, encode: fn(&V) -> Value, ) -> Col<V>

Source

pub fn eq(self, v: impl Borrow<V>) -> Pred

Source

pub fn ne(self, v: impl Borrow<V>) -> Pred

Source

pub fn lt(self, v: impl Borrow<V>) -> Pred

Source

pub fn le(self, v: impl Borrow<V>) -> Pred

Source

pub fn gt(self, v: impl Borrow<V>) -> Pred

Source

pub fn ge(self, v: impl Borrow<V>) -> Pred

Source

pub fn is_in(self, values: impl IntoIterator<Item = impl Borrow<V>>) -> Pred

column ∈ values, each encoded through this column’s own codec exactly as eq does. An empty set matches nothing, in both evaluation paths.

Source

pub fn not_in(self, values: impl IntoIterator<Item = impl Borrow<V>>) -> Pred

The complement of Col::is_in, with SQL’s NULL rule: a NULL column is unknown, so it is not selected; not_in is therefore not the same as !is_in over nullable columns, exactly as in SQL.

Source

pub fn is_null(self) -> Pred

column IS NULL.

Source

pub fn is_not_null(self) -> Pred

column IS NOT NULL.

Source

pub fn between(self, lo: impl Borrow<V>, hi: impl Borrow<V>) -> Pred

Source

pub fn asc(self) -> Sort

Source

pub fn desc(self) -> Sort

Source§

impl Col<String>

Source

pub fn contains(self, needle: impl Into<String>) -> Pred

Case-sensitive substring.

Source

pub fn starts_with(self, prefix: impl Into<String>) -> Pred

Case-sensitive prefix match.

Source

pub fn starts_with_ci(self, prefix: impl Into<String>) -> Pred

Case-insensitive prefix match.

Source

pub fn contains_ci(self, needle: impl Into<String>) -> Pred

Case-insensitive substring, what a search field wants.

Source§

impl<M: Model> Col<One<M>>

Predicates over a to-one reference column: the identity and presence tests, which need nothing but the foreign-key column already stored here.

Source

pub fn is(self, id: impl Into<ModelId<M>>) -> Pred

The reference points at exactly this row.

Source

pub fn is_one_of( self, ids: impl IntoIterator<Item = impl Into<ModelId<M>>>, ) -> Pred

The reference points at one of these rows: the set form, and what a query feeding another query compiles to. (Named apart from the generic crate::Col::is_in, which takes One values; this one takes ids, which is what a caller holds.)

Source

pub fn is_unset(self) -> Pred

The reference was never set, or a nullify rule cleared it.

Source

pub fn is_set(self) -> Pred

The reference points somewhere.

Source§

impl<M: Model> Col<One<M>>

Traversing a to-one reference in a predicate: “lodgings whose trip is done”. A to-one is a to-many of at most one, so the quantifier vocabulary is the same one the Many side uses; any reads as “its target matches, and there is one”.

Source

pub fn any(self, inner: Pred) -> Pred

Source

pub fn none(self, inner: Pred) -> Pred

Source§

impl<M: Model> Col<Option<One<M>>>

The same, over a nullable reference.

Source

pub fn any(self, inner: Pred) -> Pred

Source

pub fn none(self, inner: Pred) -> Pred

Source§

impl<M: Model> Col<Option<One<M>>>

The same tests over a nullable reference (Option<One<M>>), which is what a relation with a nullify delete rule requires the child to hold.

Source

pub fn is(self, id: impl Into<ModelId<M>>) -> Pred

Source

pub fn is_one_of( self, ids: impl IntoIterator<Item = impl Into<ModelId<M>>>, ) -> Pred

Source

pub fn is_unset(self) -> Pred

The reference was never set, or a nullify rule cleared it.

Source

pub fn is_set(self) -> Pred

The reference points somewhere.

Trait Implementations§

Source§

impl<V> Clone for Col<V>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<V> Copy for Col<V>

Auto Trait Implementations§

§

impl<V> Forget for Col<V>

§

impl<V> Freeze for Col<V>
where fn(&V) -> Value: Freeze,

§

impl<V> Move for Col<V>

§

impl<V> RefUnwindSafe for Col<V>
where fn(&V) -> Value: RefUnwindSafe,

§

impl<V> Send for Col<V>
where fn(&V) -> Value: Send,

§

impl<V> Sync for Col<V>
where fn(&V) -> Value: Sync,

§

impl<V> Unpin for Col<V>
where fn(&V) -> Value: Unpin,

§

impl<V> UnsafeUnpin for Col<V>
where fn(&V) -> Value: UnsafeUnpin,

§

impl<V> UnwindSafe for Col<V>
where fn(&V) -> Value: 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> ErasedDestructor for T
where T: 'static,

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoReactive<T, StaticMark> for T
where T: Clone + 'static,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.