pub struct Module {
pub name: String,
pub model: Option<String>,
pub fields: Vec<String>,
pub belongs_to: Vec<Relation>,
}Expand description
One application module as recorded in gize.toml (ADR-009 revision).
name is the module/table name as used on disk (snake_case, e.g. users, products).
model is the struct name, recorded only when it cannot be derived back from name
(Movie -> movies would read back as Movy); see Module::model_name.
fields reuse the CLI’s name:Type grammar verbatim (see crate::field) so the
manifest and the command line share one definition of a model. belongs_to records the
module’s 1-N relationships (ADR-014).
Fields§
§name: String§model: Option<String>§fields: Vec<String>§belongs_to: Vec<Relation>Implementations§
Source§impl Module
impl Module
Sourcepub fn named(name: impl Into<String>) -> Self
pub fn named(name: impl Into<String>) -> Self
A module with just a name and no declared shape (used by gize make app, and when
upgrading a legacy names-only manifest).
Sourcepub fn for_model(model: &ModelSpec) -> Self
pub fn for_model(model: &ModelSpec) -> Self
The module recorded for model, as gize make crud writes it to the manifest. The
struct name is stored only when deriving it from the table name would not give it back,
so manifests of models that round-trip (Post -> posts) stay as they were.
Sourcepub fn model_name(&self) -> String
pub fn model_name(&self) -> String
The model’s struct name: the recorded model, or else derived from the module/table
name (posts -> Post), which is what manifests written before model existed rely on.
Sourcepub fn model_spec(&self) -> Result<ModelSpec>
pub fn model_spec(&self) -> Result<ModelSpec>
Recover the model definition this module describes, for regenerating its code during
gize sync (ADR-009 revision). The struct name comes from Module::model_name; the
fields are re-parsed from their name:Type tokens.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Module
impl<'de> Deserialize<'de> for Module
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Module
impl StructuralPartialEq for Module
Auto Trait Implementations§
impl Freeze for Module
impl RefUnwindSafe for Module
impl Send for Module
impl Sync for Module
impl Unpin for Module
impl UnsafeUnpin for Module
impl UnwindSafe for Module
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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.