#[repr(C)]pub struct ComponentDataModel {
pub name: AzString,
pub description: AzString,
pub fields: ComponentDataFieldVec,
}Expand description
A named data model (struct definition) for code generation.
Stored in ComponentLibrary::data_models. Components reference these
by name in ComponentDataField::field_type, enabling nested/structured
data models. For example, a UserCard component might have a field
user: UserProfile where UserProfile is a ComponentDataModel.
Fields§
§name: AzStringType name, e.g. “UserProfile”, “TodoItem”
description: AzStringHuman-readable description
fields: ComponentDataFieldVecFields in this struct
Implementations§
Source§impl ComponentDataModel
impl ComponentDataModel
Sourcepub fn get_field(&self, name: &str) -> Option<&ComponentDataField>
pub fn get_field(&self, name: &str) -> Option<&ComponentDataField>
Look up a field by name.
Sourcepub fn get_default_string(&self, name: &str) -> Option<&AzString>
pub fn get_default_string(&self, name: &str) -> Option<&AzString>
Look up a field’s default value as a string, if it exists and is a String variant.
Sourcepub fn with_default(self, name: &str, value: ComponentDefaultValue) -> Self
pub fn with_default(self, name: &str, value: ComponentDefaultValue) -> Self
Clone this data model, overriding the default value for a field by name. If the field is not found, the data model is returned unchanged.
Trait Implementations§
Source§impl Clone for ComponentDataModel
impl Clone for ComponentDataModel
Source§fn clone(&self) -> ComponentDataModel
fn clone(&self) -> ComponentDataModel
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ComponentDataModel
impl Debug for ComponentDataModel
Source§impl<'de> Deserialize<'de> for ComponentDataModel
impl<'de> Deserialize<'de> for ComponentDataModel
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
A data model is a JSON object. This deliberately drives the
deserializer with deserialize_map instead of deserialize_struct:
the struct hint makes serde accept a sequence as well (the
positional encoding used by compact formats), so from_json("[]")
used to succeed and hand back a nameless, field-less model instead of
reporting that the input is not a data model at all. Every key stays
optional, so {} still deserializes to the empty model.
Source§impl Extend<ComponentDataModel> for ComponentDataModelVec
impl Extend<ComponentDataModel> for ComponentDataModelVec
Source§fn extend<T: IntoIterator<Item = ComponentDataModel>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = ComponentDataModel>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)