pub struct SchemaBuilder { /* private fields */ }Expand description
Mutable working set used while a graph is being built up.
Derived register_in bodies call SchemaBuilder::reserve before
recursing into inner fields so back-references through
SchemaType::Ref can close without infinite recursion. Once the
body is fully constructed they call SchemaBuilder::commit to
promote the reservation to a real definition.
Implementations§
Source§impl SchemaBuilder
impl SchemaBuilder
pub fn new() -> SchemaBuilder
Sourcepub fn is_registered(&self, id: &TypeId) -> bool
pub fn is_registered(&self, id: &TypeId) -> bool
true when id is already reserved or committed in this builder.
Sourcepub fn reserve(&mut self, id: TypeId)
pub fn reserve(&mut self, id: TypeId)
Reserve a slot for id so recursive references close without
infinite recursion. Must be followed by a matching
Self::commit call once the body is built.
Sourcepub fn commit(
&mut self,
id: TypeId,
name: Option<String>,
metadata: MetadataEnvelope,
body: SchemaType,
)
pub fn commit( &mut self, id: TypeId, name: Option<String>, metadata: MetadataEnvelope, body: SchemaType, )
Promote a reservation to a real definition.
metadata is attached to the body’s MetadataEnvelope (every
SchemaType node carries metadata directly; the def no longer has
a separate slot for it).
Sourcepub fn finish(self) -> Vec<SchemaTypeDef>
pub fn finish(self) -> Vec<SchemaTypeDef>
Consume the builder and return the accumulated definitions.
Sourcepub fn into_graph(self, root: SchemaType) -> SchemaGraph
pub fn into_graph(self, root: SchemaType) -> SchemaGraph
Build a SchemaGraph using root as the entry point.