pub struct GraphEncoder { /* private fields */ }Expand description
Incremental builder for a single flat wire::SchemaGraph that holds
several independent root types in one shared type-nodes pool.
Used by the agent-layer conversions, where one agent type carries a single
schema-graph whose defs are shared and whose constructor / method /
config schema roots are type-node-index values into that same graph (see
[crate::schema::agent::wit]).
Seed the builder with the agent’s named definitions via GraphEncoder::new,
then call GraphEncoder::encode_type for each inline root type (collecting
the returned indices), and finally GraphEncoder::finish to obtain the
graph with a placeholder root.
Implementations§
Source§impl GraphEncoder
impl GraphEncoder
Sourcepub fn new(defs: &[SchemaTypeDef]) -> Result<GraphEncoder, EncodeError>
pub fn new(defs: &[SchemaTypeDef]) -> Result<GraphEncoder, EncodeError>
Create a builder seeded with the given named definitions. Each def body
is encoded eagerly so forward SchemaType::Ref references resolve.
Sourcepub fn encode_type(&mut self, ty: &SchemaType) -> Result<i32, EncodeError>
pub fn encode_type(&mut self, ty: &SchemaType) -> Result<i32, EncodeError>
Flatten one (possibly recursive) schema type into the shared pool and
return its type-node-index.
Sourcepub fn finish(self) -> SchemaGraph
pub fn finish(self) -> SchemaGraph
Finish the graph. The root field is a structural placeholder (an empty
record) — agent-layer carriers never consult it; the real roots are the
indices returned by GraphEncoder::encode_type.