pub struct Schema { /* private fields */ }Expand description
Cached schema for a type that may contain flattened fields.
This is computed once per Shape and can be cached forever since type information is static.
Implementations§
Source§impl Schema
impl Schema
Sourcepub fn build(shape: &'static Shape) -> Result<Self, SchemaError>
pub fn build(shape: &'static Shape) -> Result<Self, SchemaError>
Build a schema for the given shape with flattened enum representation.
Returns an error if the type definition contains conflicts, such as duplicate field names from parent and flattened structs.
Note: This defaults to Flattened representation. For auto-detection
based on #[facet(tag = "...")] attributes, use Schema::build_auto.
Sourcepub fn build_auto(shape: &'static Shape) -> Result<Self, SchemaError>
pub fn build_auto(shape: &'static Shape) -> Result<Self, SchemaError>
Build a schema with auto-detected enum representation based on each enum’s attributes.
This inspects each flattened enum’s shape attributes to determine its representation:
#[facet(untagged)]→ Flattened#[facet(tag = "type")]→ InternallyTagged#[facet(tag = "t", content = "c")]→ AdjacentlyTagged- No attributes → Flattened (for flatten solver behavior)
For externally-tagged enums (variant name as key), use Schema::build_externally_tagged.
Sourcepub fn build_externally_tagged(
shape: &'static Shape,
) -> Result<Self, SchemaError>
pub fn build_externally_tagged( shape: &'static Shape, ) -> Result<Self, SchemaError>
Build a schema for externally-tagged enum representation (e.g., JSON).
In this representation, the variant name appears as a key and the variant’s content is nested under it. The solver will only expect to see the variant name as a top-level key, not the variant’s fields.
Sourcepub fn build_with_repr(
shape: &'static Shape,
repr: EnumRepr,
) -> Result<Self, SchemaError>
pub fn build_with_repr( shape: &'static Shape, repr: EnumRepr, ) -> Result<Self, SchemaError>
Build a schema with the specified enum representation.
Sourcepub fn resolutions(&self) -> &[Resolution]
pub fn resolutions(&self) -> &[Resolution]
Get the resolutions for this schema.