pub struct TypedTemplate { /* private fields */ }Expand description
Owns a reusable native definition, complete formal/local shapes and source metadata.
No live runtime is cloned. Metadata retains compact child edges and releases them iteratively on last-owner drop. See the module example.
Implementations§
Source§impl TypedTemplate
impl TypedTemplate
Borrows flat authored labels and local native slot mappings.
Native templates may have no authored item records.
§Examples
let t = adam_lang::CompositionBuilder::new(adam_lang::TypeRegistry::new()).finish()?;
assert!(t.authored_items().is_empty());Sourcepub fn parameters(&self) -> impl Iterator<Item = (&str, &TypeShape)>
pub fn parameters(&self) -> impl Iterator<Item = (&str, &TypeShape)>
Borrows complete formal signatures in declaration order without running factories.
- Complexity: O(c) traversal for c local declarations, with expected O(1) lookup per formal.
§Examples
let mut builder = adam_lang::CompositionBuilder::new(adam_lang::TypeRegistry::new());
builder.parameter("x", adam_lang::type_registry::TypeShape::Named(std::any::TypeId::of::<i32>()))?;
let template = builder.finish()?;
assert_eq!(template.parameters().next().unwrap().0, "x");Sourcepub fn definition_label(&self) -> &SourceLabel
pub fn definition_label(&self) -> &SourceLabel
Borrows the authored definition label, including span-free native labels.
§Examples
let template = adam_lang::CompositionBuilder::new(adam_lang::TypeRegistry::new()).finish()?;
assert!(template.definition_label().location.is_none());Sourcepub fn instantiate(
&self,
destination: &mut ParsedSheet,
bindings: &[(&str, CellId)],
) -> Result<Instance, ModuleDiagnostic>
pub fn instantiate( &self, destination: &mut ParsedSheet, bindings: &[(&str, CellId)], ) -> Result<Instance, ModuleDiagnostic>
Instantiates into an existing source-free or parsed destination.
Named bindings must be complete, distinct, registered in the destination and exactly shape-compatible. Native checks enforce cell kinds and specialization. Binding/structural rejection precedes all mutation. Later initializer/body factory errors leave the destination safely discardable, not rolled back. Private names never enter root lookup maps; full private shapes and flat occurrence, method and conditional origins survive definition and returned instance drop.
§Errors
Reports binding, native structural/capacity, initializer or body-factory failures. Native diagnostics retain span-free labels unless a real label was supplied.
- Complexity: Expected O(b + n + d + o + c + r + m + k + s) bindings, shape nodes, unique metadata DAG size, occurrences, local cell mappings, relationships and surviving methods, conditional mappings k and previously retained sources s, plus native expansion and factory costs.
§Examples
See the module example.
Sourcepub fn is_relationship_only(&self) -> bool
pub fn is_relationship_only(&self) -> bool
Returns native relationship-only eligibility before any source specialization.
§Examples
let template = adam_lang::CompositionBuilder::new(adam_lang::TypeRegistry::new()).finish()?;
assert!(template.is_relationship_only());