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
impl InfinityModule
pub fn new() -> Self
Sourcepub fn add_node(&mut self, node: Inode) -> NodeId
pub fn add_node(&mut self, node: Inode) -> NodeId
Alias for InfinityModule::push, mirroring Module::add_node.
pub fn get(&self, id: NodeId) -> Option<&Inode>
pub fn get_mut(&mut self, id: NodeId) -> Option<&mut Inode>
pub fn node_mut(&mut self, id: NodeId) -> Result<&mut Inode, Error>
pub fn nodes(&self) -> &[Inode]
pub fn node_count(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn root(&self) -> Option<NodeId>
pub fn set_root(&mut self, root: Option<NodeId>)
pub fn bindings(&self) -> &[(String, NodeId)]
Sourcepub fn bind(&mut self, name: impl Into<String>, id: NodeId)
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.
pub fn annotations(&self) -> &[Annotation]
pub fn annotate(&mut self, node: NodeId, kind: AnnotationKind)
Sourcepub fn clear_annotations(&mut self)
pub fn clear_annotations(&mut self)
Drop every annotation.
Sourcepub fn remove_binding(&mut self, name: &str) -> Option<NodeId>
pub fn remove_binding(&mut self, name: &str) -> Option<NodeId>
Remove a binding by name; returns the old target when present.
pub fn provenance(&self) -> Option<&Provenance>
Sourcepub fn has_secret(&self) -> bool
pub fn has_secret(&self) -> bool
True when the module holds a structural secret literal.
Sourcepub fn structurally_eq(&self, other: &Self) -> bool
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.
pub fn set_provenance(&mut self, provenance: Option<Provenance>)
Sourcepub fn roots(&self) -> Vec<NodeId>
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.
Sourcepub fn edges(&self) -> Vec<(NodeId, NodeId)>
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.
Sourcepub fn dependency_map(&self) -> HashMap<NodeId, Vec<NodeId>>
pub fn dependency_map(&self) -> HashMap<NodeId, Vec<NodeId>>
Reverse adjacency (dependent → dependencies).
Sourcepub fn validate_structure(
&self,
max_nodes: u64,
max_depth: u32,
) -> Result<(), Error>
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.
Sourcepub fn check_acyclic(&self, count: u32) -> Result<(), Error>
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).
Sourcepub fn check_depth(&self, max_depth: u32) -> Result<(), Error>
pub fn check_depth(&self, max_depth: u32) -> Result<(), Error>
Depth check over the derived dependency graph (iterative).
Sourcepub fn string_bytes(&self) -> u64
pub fn string_bytes(&self) -> u64
Total string payload bytes (heap size before deduplication).
Sourcepub fn from_parts(
nodes: Vec<Inode>,
root: Option<NodeId>,
bindings: Vec<(String, NodeId)>,
annotations: Vec<Annotation>,
provenance: Option<Provenance>,
) -> Self
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
impl Clone for InfinityModule
Source§impl Debug for InfinityModule
impl Debug for InfinityModule
Source§impl Default for InfinityModule
impl Default for InfinityModule
Source§impl PartialEq for InfinityModule
impl PartialEq for InfinityModule
Source§fn eq(&self, other: &Self) -> bool
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.