Schema

Trait Schema 

Source
pub trait Schema: Send + Sync {
    // Required methods
    fn shape_id(&self) -> &ShapeId;
    fn shape_type(&self) -> ShapeType;
    fn traits(&self) -> &TraitMap;

    // Provided methods
    fn member_name(&self) -> Option<&str> { ... }
    fn member_schema(&self, _name: &str) -> Option<&dyn Schema> { ... }
    fn member_schema_by_index(&self, _index: usize) -> Option<&dyn Schema> { ... }
    fn member(&self) -> Option<&dyn Schema> { ... }
    fn key(&self) -> Option<&dyn Schema> { ... }
    fn members(&self) -> Box<dyn Iterator<Item = &dyn Schema> + '_> { ... }
    fn member_index(&self) -> Option<usize> { ... }
}
Expand description

Core trait representing a Smithy schema at runtime.

A schema is a lightweight runtime representation of a Smithy shape, containing the shape’s ID, type, traits, and references to member schemas.

Required Methods§

Source

fn shape_id(&self) -> &ShapeId

Returns the Shape ID of this schema.

Source

fn shape_type(&self) -> ShapeType

Returns the shape type.

Source

fn traits(&self) -> &TraitMap

Returns the traits associated with this schema.

Provided Methods§

Source

fn member_name(&self) -> Option<&str>

Returns the member name if this is a member schema.

Source

fn member_schema(&self, _name: &str) -> Option<&dyn Schema>

Returns the member schema by name (for structures and unions).

Source

fn member_schema_by_index(&self, _index: usize) -> Option<&dyn Schema>

Returns the member schema by position index (for structures and unions).

This is an optimization for generated code to avoid string lookups. Consumer code should not rely on specific position values as they may change.

Source

fn member(&self) -> Option<&dyn Schema>

Returns the member schema for collections (list member or map value).

Source

fn key(&self) -> Option<&dyn Schema>

Returns the key schema for maps.

Source

fn members(&self) -> Box<dyn Iterator<Item = &dyn Schema> + '_>

Returns an iterator over member schemas (for structures and unions).

Source

fn member_index(&self) -> Option<usize>

Returns the member index for member schemas.

This is used internally by generated code for efficient member lookup. Returns None if not applicable or not a member schema.

Implementors§