Schema

Struct Schema 

Source
pub struct Schema {
    pub models: IndexMap<ModelId, Model>,
}

Fields§

§models: IndexMap<ModelId, Model>

Implementations§

Source§

impl Schema

Source

pub fn from_macro(models: &[Model]) -> Result<Self>

Source

pub fn field(&self, id: FieldId) -> &Field

Get a field by ID

Source

pub fn variant(&self, id: VariantId) -> &EnumVariant

Get a variant by ID

Source

pub fn models(&self) -> impl Iterator<Item = &Model>

Source

pub fn get_model(&self, id: impl Into<ModelId>) -> Option<&Model>

Try to get a model by ID, returning None if not found.

Source

pub fn model(&self, id: impl Into<ModelId>) -> &Model

Get a model by ID

Source

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
Source

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.

Source

pub fn resolve_field_path<'a>(&'a self, path: &Path) -> Option<&'a Field>

Trait Implementations§

Source§

impl Debug for Schema

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Schema

Source§

fn default() -> Schema

Returns the “default value” for a type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V