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§
Sourcefn shape_type(&self) -> ShapeType
fn shape_type(&self) -> ShapeType
Returns the shape type.
Provided Methods§
Sourcefn member_name(&self) -> Option<&str>
fn member_name(&self) -> Option<&str>
Returns the member name if this is a member schema.
Sourcefn member_schema(&self, _name: &str) -> Option<&dyn Schema>
fn member_schema(&self, _name: &str) -> Option<&dyn Schema>
Returns the member schema by name (for structures and unions).
Sourcefn member_schema_by_index(&self, _index: usize) -> Option<&dyn Schema>
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.
Sourcefn member(&self) -> Option<&dyn Schema>
fn member(&self) -> Option<&dyn Schema>
Returns the member schema for collections (list member or map value).
Sourcefn members(&self) -> Box<dyn Iterator<Item = &dyn Schema> + '_>
fn members(&self) -> Box<dyn Iterator<Item = &dyn Schema> + '_>
Returns an iterator over member schemas (for structures and unions).
Sourcefn member_index(&self) -> Option<usize>
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.