pub struct Field {
pub id: FieldId,
pub name: FieldName,
pub ty: FieldTy,
pub nullable: bool,
pub primary_key: bool,
pub auto: Option<AutoStrategy>,
pub constraints: Vec<Constraint>,
pub variant: Option<VariantId>,
}Fields§
§id: FieldIdUniquely identifies the field within the containing model.
name: FieldNameThe field name
ty: FieldTyPrimitive, relation, composite, …
nullable: boolTrue if the field can be nullable (None in Rust).
primary_key: boolTrue if the field is part of the primary key
auto: Option<AutoStrategy>Specified if and how Toasty should automatically populate this field for new values
constraints: Vec<Constraint>Any additional field constraints
variant: Option<VariantId>If this field belongs to an enum variant, identifies that variant.
None for fields on root models and embedded structs.
Implementations§
Source§impl Field
impl Field
Sourcepub fn primary_key(&self) -> bool
pub fn primary_key(&self) -> bool
Gets the primary key.
Sourcepub fn auto(&self) -> Option<&AutoStrategy>
pub fn auto(&self) -> Option<&AutoStrategy>
Gets the [Auto].
pub fn is_auto_increment(&self) -> bool
pub fn is_relation(&self) -> bool
Sourcepub fn full_name(&self, schema: &Schema) -> String
pub fn full_name(&self, schema: &Schema) -> String
Returns a fully qualified name for the field.
Sourcepub fn relation_target_id(&self) -> Option<ModelId>
pub fn relation_target_id(&self) -> Option<ModelId>
If the field is a relation, return the relation’s target ModelId.
Sourcepub fn relation_target<'a>(&self, schema: &'a Schema) -> Option<&'a Model>
pub fn relation_target<'a>(&self, schema: &'a Schema) -> Option<&'a Model>
If the field is a relation, return the target of the relation.
Sourcepub fn expr_ty(&self) -> &Type
pub fn expr_ty(&self) -> &Type
The type the field evaluates too. This is the “expression type”.
pub fn pair(&self) -> Option<FieldId>
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more