Skip to main content

TypedTemplate

Struct TypedTemplate 

Source
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

Source

pub fn authored_items(&self) -> &[AuthoredItem]

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());
Source

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");
Source

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());
Source

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.

Source

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());

Trait Implementations§

Source§

impl Clone for TypedTemplate

Source§

fn clone(&self) -> Self

Shares immutable recipes and metadata without copying any live execution state.

1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.