pub struct Schema {
pub models: IndexMap<ModelId, Model>,
}Fields§
§models: IndexMap<ModelId, Model>Implementations§
Source§impl Schema
impl Schema
pub fn from_macro(models: &[Model]) -> Result<Self>
Sourcepub fn variant(&self, id: VariantId) -> &EnumVariant
pub fn variant(&self, id: VariantId) -> &EnumVariant
Get a variant by ID
pub fn models(&self) -> impl Iterator<Item = &Model>
Sourcepub fn get_model(&self, id: impl Into<ModelId>) -> Option<&Model>
pub fn get_model(&self, id: impl Into<ModelId>) -> Option<&Model>
Try to get a model by ID, returning None if not found.
Sourcepub fn resolve<'a>(
&'a self,
root: &'a Model,
projection: &Projection,
) -> Option<Resolved<'a>>
pub fn resolve<'a>( &'a self, root: &'a Model, projection: &Projection, ) -> Option<Resolved<'a>>
Resolve a projection through the schema, returning either a field or an enum variant.
Starting from the root model, walks through each step of the projection, resolving fields, following relations/embedded types, and recognizing enum variant discriminant access.
Returns None if:
- The projection is empty
- Any step references an invalid field/variant index
- A step tries to project through a primitive type
Sourcepub fn resolve_field<'a>(
&'a self,
root: &'a Model,
projection: &Projection,
) -> Option<&'a Field>
pub fn resolve_field<'a>( &'a self, root: &'a Model, projection: &Projection, ) -> Option<&'a Field>
Resolve a projection to a field, walking through the schema.
Returns None if the projection is empty, invalid, or resolves to an
enum variant rather than a field.
pub fn resolve_field_path<'a>(&'a self, path: &Path) -> Option<&'a Field>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Schema
impl RefUnwindSafe for Schema
impl Send for Schema
impl Sync for Schema
impl Unpin for Schema
impl UnwindSafe for Schema
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