Skip to main content

InfinityModule

Struct InfinityModule 

Source
pub struct InfinityModule { /* private fields */ }
Expand description

A canonical Active Infinity module.

The struct is an arena of Inode plus roots, bindings, annotations and provenance. Edges are derived from node children, so a module can never hold an edge table inconsistent with its nodes.

Implementations§

Source§

impl InfinityModule

Source

pub fn new() -> Self

Source

pub fn push(&mut self, node: Inode) -> NodeId

Add a node, returning its id.

Source

pub fn add_node(&mut self, node: Inode) -> NodeId

Alias for InfinityModule::push, mirroring Module::add_node.

Source

pub fn get(&self, id: NodeId) -> Option<&Inode>

Source

pub fn get_mut(&mut self, id: NodeId) -> Option<&mut Inode>

Source

pub fn node_mut(&mut self, id: NodeId) -> Result<&mut Inode, Error>

Source

pub fn nodes(&self) -> &[Inode]

Source

pub fn node_count(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn root(&self) -> Option<NodeId>

Source

pub fn set_root(&mut self, root: Option<NodeId>)

Source

pub fn bindings(&self) -> &[(String, NodeId)]

Source

pub fn bind(&mut self, name: impl Into<String>, id: NodeId)

Bind a name to a node. Replaces an existing binding with the same name.

Source

pub fn annotations(&self) -> &[Annotation]

Source

pub fn annotate(&mut self, node: NodeId, kind: AnnotationKind)

Source

pub fn clear_annotations(&mut self)

Drop every annotation.

Source

pub fn remove_binding(&mut self, name: &str) -> Option<NodeId>

Remove a binding by name; returns the old target when present.

Source

pub fn provenance(&self) -> Option<&Provenance>

Source

pub fn has_secret(&self) -> bool

True when the module holds a structural secret literal.

Source

pub fn structurally_eq(&self, other: &Self) -> bool

Canonical structural equality, blinding secret payloads.

This is what PartialEq implements; it is also available by name for readers who want the intent spelled out.

Source

pub fn set_provenance(&mut self, provenance: Option<Provenance>)

Source

pub fn roots(&self) -> Vec<NodeId>

Roots used to define the reachable graph: the module root, every binding, every annotation subject, and provenance-only references.

Source

pub fn edges(&self) -> Vec<(NodeId, NodeId)>

Derived dependency edges, direction dependency → dependent, sorted and deduplicated. Nodes that reference where they are referenced from are normal; the graph is a DAG after Self::validate_structure.

Source

pub fn dependency_map(&self) -> HashMap<NodeId, Vec<NodeId>>

Reverse adjacency (dependent → dependencies).

Source

pub fn validate_structure( &self, max_nodes: u64, max_depth: u32, ) -> Result<(), Error>

Check every structural invariant the wire format also enforces.

max_nodes and max_depth bound the work so a hostile module cannot make this function hang or recurse without limit.

Source

pub fn check_acyclic(&self, count: u32) -> Result<(), Error>

Iterative cycle detection over the derived dependency graph.

Explicit stack: a hostile 4M-node chain must not overflow the thread stack (active-core treats cycles as fatal, so this is a hard invariant, not a hint).

Source

pub fn check_depth(&self, max_depth: u32) -> Result<(), Error>

Depth check over the derived dependency graph (iterative).

Source

pub fn string_bytes(&self) -> u64

Total string payload bytes (heap size before deduplication).

Source

pub fn from_parts( nodes: Vec<Inode>, root: Option<NodeId>, bindings: Vec<(String, NodeId)>, annotations: Vec<Annotation>, provenance: Option<Provenance>, ) -> Self

Rebuild a module from decoded parts (used by the decoder and the stream reassembler).

Trait Implementations§

Source§

impl Clone for InfinityModule

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for InfinityModule

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for InfinityModule

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for InfinityModule

Source§

fn eq(&self, other: &Self) -> bool

Canonical structural equality: two modules are equal when their canonical forms match, so arena order, table field order and blob numbering are irrelevant.

Secret contents are never compared — only the fact that a secret is there — so equality can never become a guessing oracle, and a module holding a secret is equal to a structurally identical copy of itself. Use SecretBytes directly when you need the anti-oracle behaviour of two secret values.

1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. 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.