pub struct ModelSpec {
pub name: String,
pub fields: Vec<Field>,
pub relations: Vec<Relation>,
}Expand description
A model: a name plus its fields and relationships, as produced by
gize make crud Name f:T author:belongs_to:users ....
Each relationship is also expanded into a synthetic <name>_id: Uuid Field appended
to fields, so every field-driven template (model, dto, repository, …) picks up the
foreign-key column for free; only the migration consults relations directly, to emit the
FOREIGN KEY constraint.
Fields§
§name: String§fields: Vec<Field>§relations: Vec<Relation>Implementations§
Source§impl ModelSpec
impl ModelSpec
Sourcepub fn parse(name: impl Into<String>, tokens: &[String]) -> Result<Self>
pub fn parse(name: impl Into<String>, tokens: &[String]) -> Result<Self>
Build a model spec from a name and raw tokens. A token of the form
name:belongs_to:target is parsed as a relationship; anything else is a scalar
name:Type field.
Sourcepub fn to_field_tokens(&self) -> Vec<String>
pub fn to_field_tokens(&self) -> Vec<String>
Serialize the scalar fields back into canonical name:Type tokens, for recording the
model’s shape in gize.toml (ADR-009 revision). Synthetic foreign-key columns are
omitted — relationships are recorded separately under [[module.belongs_to]].
Trait Implementations§
impl Eq for ModelSpec
impl StructuralPartialEq for ModelSpec
Auto Trait Implementations§
impl Freeze for ModelSpec
impl RefUnwindSafe for ModelSpec
impl Send for ModelSpec
impl Sync for ModelSpec
impl Unpin for ModelSpec
impl UnsafeUnpin for ModelSpec
impl UnwindSafe for ModelSpec
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.