Field

Enum Field 

Source
pub enum Field {
    Primitive(FieldPrimitive),
    Struct(FieldStruct),
    Enum(FieldEnum),
    Relation(FieldRelation),
}
Expand description

Maps a model field to its database storage representation.

Different field types have different storage strategies:

  • Primitive fields map to a single column
  • Struct fields flatten an embedded struct to multiple columns
  • Enum fields map to a discriminant column plus per-variant data columns
  • Relation fields (BelongsTo, HasMany, HasOne) don’t have direct column storage

Variants§

§

Primitive(FieldPrimitive)

A primitive field stored in a single column.

§

Struct(FieldStruct)

An embedded struct field flattened into multiple columns.

§

Enum(FieldEnum)

An embedded enum field stored as a discriminant column plus per-variant data columns.

§

Relation(FieldRelation)

A relation field that doesn’t map to columns in this table.

Implementations§

Source§

impl Field

Source

pub fn field_mask(&self) -> PathFieldSet

Returns the update coverage mask for this field.

Each primitive (leaf) field in the model is assigned a unique bit. The mask for a given mapping field is the set of those bits that correspond to the primitives it covers:

  • Primitive → singleton set containing only its own bit
  • Struct → union of all nested primitive bits (recursively)
  • Enum → singleton set (the whole enum value changes atomically)
  • Relation → singleton set (assigned a bit for uniform tracking)

Masks are used during update lowering to determine whether a partial update fully covers an embedded field or only touches some of its sub-fields. Intersecting changed_mask with a field’s field_mask yields the subset of that field’s primitives being updated; equality with the full field_mask means full coverage.

Source

pub fn sub_projection(&self) -> &Projection

Returns the sub-projection from the root model field to this field within the embedded type hierarchy. Identity for root-level fields.

Source

pub fn is_relation(&self) -> bool

Source

pub fn as_primitive(&self) -> Option<&FieldPrimitive>

Source

pub fn as_primitive_mut(&mut self) -> Option<&mut FieldPrimitive>

Source

pub fn as_struct(&self) -> Option<&FieldStruct>

Source

pub fn as_enum(&self) -> Option<&FieldEnum>

Source

pub fn columns(&self) -> impl Iterator<Item = (ColumnId, usize)> + '_

Returns an iterator over all (column, lowering) pairs impacted by this field.

For primitive fields, yields a single pair. For struct fields, yields all flattened columns. For enum fields, yields the discriminant column plus all variant data columns. For relation fields, yields nothing.

Trait Implementations§

Source§

impl Clone for Field

Source§

fn clone(&self) -> Field

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 Debug for Field

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Field

§

impl RefUnwindSafe for Field

§

impl Send for Field

§

impl Sync for Field

§

impl Unpin for Field

§

impl UnwindSafe for Field

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V