pub struct SchemaDocument {
pub nodes: Vec<SchemaNode>,
pub root: SchemaNodeId,
pub types: IndexMap<Identifier, SchemaNodeId>,
pub exports: IndexSet<Identifier>,
pub imports: IndexMap<Identifier, SchemaImport>,
pub root_codegen: RootCodegen,
pub codegen_defaults: CodegenDefaults,
}Expand description
Schema document with arena-based node storage
Fields§
§nodes: Vec<SchemaNode>All schema nodes stored in a flat vector
root: SchemaNodeIdRoot node reference
types: IndexMap<Identifier, SchemaNodeId>Named type definitions declared by this document’s own $types.
exports: IndexSet<Identifier>Names exposed to importers via $types.<alias>.<name>. Always a subset
of types.keys(). When the source omits $export, this is identical to
types.keys().
imports: IndexMap<Identifier, SchemaImport>Imported schemas keyed by the alias declared in $import.
root_codegen: RootCodegenRoot-level codegen settings from $codegen.
codegen_defaults: CodegenDefaultsRoot-level default codegen settings from $codegen-defaults.
Implementations§
Source§impl SchemaDocument
impl SchemaDocument
Sourcepub fn of<T: BuildSchema + 'static>() -> SchemaDocument
pub fn of<T: BuildSchema + 'static>() -> SchemaDocument
Source§impl SchemaDocument
impl SchemaDocument
Sourcepub fn node(&self, id: SchemaNodeId) -> &SchemaNode
pub fn node(&self, id: SchemaNodeId) -> &SchemaNode
Get a reference to a node
Sourcepub fn node_mut(&mut self, id: SchemaNodeId) -> &mut SchemaNode
pub fn node_mut(&mut self, id: SchemaNodeId) -> &mut SchemaNode
Get a mutable reference to a node
Sourcepub fn create_node(&mut self, content: SchemaNodeContent) -> SchemaNodeId
pub fn create_node(&mut self, content: SchemaNodeContent) -> SchemaNodeId
Create a new node and return its ID
Sourcepub fn register_type(&mut self, name: Identifier, node_id: SchemaNodeId)
pub fn register_type(&mut self, name: Identifier, node_id: SchemaNodeId)
Register a named type
Sourcepub fn get_type(&self, name: &Identifier) -> Option<SchemaNodeId>
pub fn get_type(&self, name: &Identifier) -> Option<SchemaNodeId>
Look up a named type
Sourcepub fn resolve_reference(
&self,
reference: &TypeReference,
) -> Option<SchemaNodeId>
pub fn resolve_reference( &self, reference: &TypeReference, ) -> Option<SchemaNodeId>
Resolve a type reference to an arena node ID.
Sourcepub fn reference_name<'a>(
&'a self,
reference: &'a TypeReference,
) -> Option<TypeReferenceName<'a>>
pub fn reference_name<'a>( &'a self, reference: &'a TypeReference, ) -> Option<TypeReferenceName<'a>>
Return the user-facing name for a type reference when it is nameable.
Sourcepub fn display_reference(&self, reference: &TypeReference) -> String
pub fn display_reference(&self, reference: &TypeReference) -> String
Best-effort display name for diagnostics.
Trait Implementations§
Source§impl Clone for SchemaDocument
impl Clone for SchemaDocument
Source§fn clone(&self) -> SchemaDocument
fn clone(&self) -> SchemaDocument
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more