pub struct SheetTemplate { /* private fields */ }Expand description
Owns an immutable ordered graph recipe, independent of any live sheet.
Parameters alias bindings; private cells and methods are fresh per instance. Destruction releases last-owned inclusion edges iteratively; shared children and their factories remain alive until their last strong owner releases them.
§Examples
See the module example.
Implementations§
Source§impl SheetTemplate
impl SheetTemplate
Sourcepub fn instantiate(
&self,
destination: &mut Sheet,
bindings: &[(&str, CellId)],
) -> Result<Instance, TemplateError>
pub fn instantiate( &self, destination: &mut Sheet, bindings: &[(&str, CellId)], ) -> Result<Instance, TemplateError>
Expands this recipe into destination, preserving bound-cell identities and values.
Binding, declared structure, expanded sizes, result reservation and empty specialized relationships are checked before mutation or factory calls, including relationships in inactive branches. A source output removes its entire method. Every authored method factory is checked against its declared edges/types before pruning or registration, even when that method writes a source. Out-cell arguments are unsupported. Later factory, allocation or native failures may leave partial structure; the destination remains safely discardable. Factories run only here, never at propagation.
§Errors
Returns binding errors for unknown, missing, repeated, aliased, invalid,
out-kind, or wrongly typed actuals. Returns TemplateError::Construction
for initializer, method, policy, relationship and empty-specialization failures,
retaining the exact definition, authored site and actual inclusion chain.
Its source preserves the original TemplateError::Factory,
TemplateError::InvalidDefinition, TemplateError::Runtime or
TemplateError::EmptyRelationship. Returns TemplateError::Capacity
without a declaration site on checked-size overflow or failed reservation.
A conditional construction failure returns TemplateError::ConditionalConstruction,
retaining its definition, registration ordinal and actual root-to-child inclusion
sites. Its source is the original TemplateError::ConditionalFactory,
TemplateError::InvalidDefinition, TemplateError::Capacity or native
construction error.
- Complexity: Expected O(d + c + b + Σ(m² × e)) time and O(d + c + b + e + r + h) additional space for expanded declarations d, cells c, bindings b, relationships r, depth h, and each relationship’s m methods of at most e edges, excluding factory costs.
§Examples
See the module example.
Sourcepub fn check_source_bindings(
&self,
bindings: &[(&str, bool)],
) -> Result<(), TemplateError>
pub fn check_source_bindings( &self, bindings: &[(&str, bool)], ) -> Result<(), TemplateError>
Checks complete named formal source statuses without constructing a live sheet.
Uses the same whole-method pruning preflight as Self::instantiate.
No initializer, method, policy, or conditional factory executes.
§Errors
Rejects missing, unknown or repeated names, capacity overflow, or a constituent relationship left without a method, including inactive branches.
- Complexity: expected O(bc + w) time and O(k + h) space for b bindings, c root cells, and local checking work w across distinct (recipe, complete source mask) specializations. k counts specializations and their mask cells, and h is inclusion depth. Distinct masks can still grow exponentially.
§Examples
let mut builder = adam_rs::TemplateBuilder::new();
builder.parameter::<i32>("x")?;
builder.finish()?.check_source_bindings(&[("x", true)])?;Source§impl SheetTemplate
impl SheetTemplate
Sourcepub fn parameter_names(&self) -> impl Iterator<Item = &str>
pub fn parameter_names(&self) -> impl Iterator<Item = &str>
Borrows formal names in declaration order, excluding private cells.
- Complexity: O(c) traversal for c local declarations.
§Examples
let mut builder = adam_rs::TemplateBuilder::new();
builder.parameter::<i32>("value")?;
assert_eq!(builder.finish()?.parameter_names().collect::<Vec<_>>(), ["value"]);Sourcepub fn id(&self) -> TemplateId
pub fn id(&self) -> TemplateId
Returns this recipe’s immutable identity without retaining its factories or children.
§Examples
let template = adam_rs::TemplateBuilder::new().finish()?;
assert_eq!(template.id(), template.id());Source§impl SheetTemplate
impl SheetTemplate
Sourcepub fn is_relationship_only(&self) -> bool
pub fn is_relationship_only(&self) -> bool
Returns whether expansion contains only relationships and parameter declarations.
Private cells, policies, outputs and conditionals disqualify a recipe transitively. An empty recipe qualifies, independently of source specialization.
§Examples
assert!(TemplateBuilder::new().finish()?.is_relationship_only());Trait Implementations§
Source§impl Drop for SheetTemplate
impl Drop for SheetTemplate
Source§fn drop(&mut self)
fn drop(&mut self)
Releases uniquely owned inclusion descendants without recursive destruction.
Shared children retain their recipes unchanged. Detaching a uniquely owned child’s edges before dropping it bounds destructor call depth independently of inclusion nesting.
- Complexity: O(n) time for released recipe storage n, excluding captured-value destructors; O(w) additional space for the maximum pending relationship edges w.