pub enum FieldTy {
Primitive(FieldPrimitive),
Embedded(Embedded),
BelongsTo(BelongsTo),
HasMany(HasMany),
HasOne(HasOne),
}Expand description
The type of a Field, distinguishing primitives, embedded types, and
relation variants.
§Examples
use toasty_core::schema::app::{FieldPrimitive, FieldTy};
use toasty_core::stmt::Type;
let ty = FieldTy::Primitive(FieldPrimitive {
ty: Type::String,
storage_ty: None,
serialize: None,
});
assert!(ty.is_primitive());
assert!(!ty.is_relation());Variants§
Primitive(FieldPrimitive)
A primitive (scalar) field backed by a single column.
Embedded(Embedded)
An embedded struct or enum, flattened into the parent table.
BelongsTo(BelongsTo)
The owning side of a relationship (stores the foreign key).
HasMany(HasMany)
The inverse side of a one-to-many relationship.
HasOne(HasOne)
The inverse side of a one-to-one relationship.
Implementations§
Source§impl FieldTy
impl FieldTy
Sourcepub fn is_primitive(&self) -> bool
pub fn is_primitive(&self) -> bool
Returns true if this is a FieldTy::Primitive.
Sourcepub fn as_primitive(&self) -> Option<&FieldPrimitive>
pub fn as_primitive(&self) -> Option<&FieldPrimitive>
Returns the inner FieldPrimitive if this is a primitive field.
Sourcepub fn as_primitive_unwrap(&self) -> &FieldPrimitive
pub fn as_primitive_unwrap(&self) -> &FieldPrimitive
Returns the inner FieldPrimitive, panicking if this is not a
primitive field.
§Panics
Panics if self is not FieldTy::Primitive.
Sourcepub fn as_primitive_mut_unwrap(&mut self) -> &mut FieldPrimitive
pub fn as_primitive_mut_unwrap(&mut self) -> &mut FieldPrimitive
Returns a mutable reference to the inner FieldPrimitive, panicking
if this is not a primitive field.
§Panics
Panics if self is not FieldTy::Primitive.
Sourcepub fn is_embedded(&self) -> bool
pub fn is_embedded(&self) -> bool
Returns true if this is a FieldTy::Embedded.
Sourcepub fn as_embedded(&self) -> Option<&Embedded>
pub fn as_embedded(&self) -> Option<&Embedded>
Returns the inner Embedded if this is an embedded field.
Sourcepub fn as_embedded_unwrap(&self) -> &Embedded
pub fn as_embedded_unwrap(&self) -> &Embedded
Returns the inner Embedded, panicking if this is not an embedded
field.
§Panics
Panics if self is not FieldTy::Embedded.
Sourcepub fn as_embedded_mut_unwrap(&mut self) -> &mut Embedded
pub fn as_embedded_mut_unwrap(&mut self) -> &mut Embedded
Returns a mutable reference to the inner Embedded, panicking if
this is not an embedded field.
§Panics
Panics if self is not FieldTy::Embedded.
Sourcepub fn is_relation(&self) -> bool
pub fn is_relation(&self) -> bool
Returns true if this is a relation type (BelongsTo, HasMany, or
HasOne).
Sourcepub fn is_has_many(&self) -> bool
pub fn is_has_many(&self) -> bool
Returns true if this is a FieldTy::HasMany.
Sourcepub fn as_has_many(&self) -> Option<&HasMany>
pub fn as_has_many(&self) -> Option<&HasMany>
Returns the inner HasMany if this is a has-many field.
Sourcepub fn as_has_many_unwrap(&self) -> &HasMany
pub fn as_has_many_unwrap(&self) -> &HasMany
Returns the inner HasMany, panicking if this is not a has-many
field.
§Panics
Panics if self is not FieldTy::HasMany.
Sourcepub fn as_has_many_mut_unwrap(&mut self) -> &mut HasMany
pub fn as_has_many_mut_unwrap(&mut self) -> &mut HasMany
Returns a mutable reference to the inner HasMany, panicking if
this is not a has-many field.
§Panics
Panics if self is not FieldTy::HasMany.
Sourcepub fn as_has_one(&self) -> Option<&HasOne>
pub fn as_has_one(&self) -> Option<&HasOne>
Returns the inner HasOne if this is a has-one field.
Sourcepub fn is_has_one(&self) -> bool
pub fn is_has_one(&self) -> bool
Returns true if this is a FieldTy::HasOne.
Sourcepub fn as_has_one_unwrap(&self) -> &HasOne
pub fn as_has_one_unwrap(&self) -> &HasOne
Returns the inner HasOne, panicking if this is not a has-one field.
§Panics
Panics if self is not FieldTy::HasOne.
Sourcepub fn as_has_one_mut_unwrap(&mut self) -> &mut HasOne
pub fn as_has_one_mut_unwrap(&mut self) -> &mut HasOne
Returns a mutable reference to the inner HasOne, panicking if
this is not a has-one field.
§Panics
Panics if self is not FieldTy::HasOne.
Sourcepub fn is_belongs_to(&self) -> bool
pub fn is_belongs_to(&self) -> bool
Returns true if this is a FieldTy::BelongsTo.
Sourcepub fn as_belongs_to(&self) -> Option<&BelongsTo>
pub fn as_belongs_to(&self) -> Option<&BelongsTo>
Returns the inner BelongsTo if this is a belongs-to field.
Sourcepub fn as_belongs_to_unwrap(&self) -> &BelongsTo
pub fn as_belongs_to_unwrap(&self) -> &BelongsTo
Returns the inner BelongsTo, panicking if this is not a belongs-to
field.
§Panics
Panics if self is not FieldTy::BelongsTo.
Sourcepub fn as_belongs_to_mut_unwrap(&mut self) -> &mut BelongsTo
pub fn as_belongs_to_mut_unwrap(&mut self) -> &mut BelongsTo
Returns a mutable reference to the inner BelongsTo, panicking if
this is not a belongs-to field.
§Panics
Panics if self is not FieldTy::BelongsTo.