Skip to main content

ModelAccess

Trait ModelAccess 

Source
pub trait ModelAccess {
    // Required methods
    fn get_nodes(&self) -> Option<&HashMap<String, Arc<StaticNode>>>;
    fn get_edges(&self) -> Option<&HashMap<String, Vec<String>>>;
    fn get_reverse_edges(&self) -> Option<&HashMap<String, Vec<String>>>;
    fn get_nodes_by_nodegroup(
        &self,
    ) -> Option<&HashMap<String, Vec<Arc<StaticNode>>>>;
    fn get_nodegroups(&self) -> Option<&HashMap<String, Arc<StaticNodegroup>>>;
    fn get_permitted_nodegroups(&self) -> HashMap<String, PermissionRule>;

    // Provided methods
    fn get_root_node(&self) -> Result<Arc<StaticNode>, String> { ... }
    fn get_child_nodes(
        &self,
        node_id: &str,
    ) -> Result<HashMap<String, Arc<StaticNode>>, String> { ... }
}
Expand description

Trait for accessing model data (nodes, edges, nodegroups)

This abstracts the model registry access pattern so that:

  • WASM can use thread-local MODEL_REGISTRY
  • Python can use a different storage mechanism
  • Tests can use mock implementations

Required Methods§

Source

fn get_nodes(&self) -> Option<&HashMap<String, Arc<StaticNode>>>

Get all nodes by ID

Source

fn get_edges(&self) -> Option<&HashMap<String, Vec<String>>>

Get edges (parent_nodeid -> child_nodeids)

Source

fn get_reverse_edges(&self) -> Option<&HashMap<String, Vec<String>>>

Get reverse edges (child_nodeid -> parent_nodeids)

Source

fn get_nodes_by_nodegroup( &self, ) -> Option<&HashMap<String, Vec<Arc<StaticNode>>>>

Get nodes grouped by nodegroup

Source

fn get_nodegroups(&self) -> Option<&HashMap<String, Arc<StaticNodegroup>>>

Get all nodegroups by ID

Source

fn get_permitted_nodegroups(&self) -> HashMap<String, PermissionRule>

Get permitted nodegroups as permission rules. Each rule may be a simple boolean or a conditional (per-tile) filter.

Provided Methods§

Source

fn get_root_node(&self) -> Result<Arc<StaticNode>, String>

Get the root node of the graph. Default implementation prefers istopnode, with fallback to scanning for nodes with no nodegroup_id.

Source

fn get_child_nodes( &self, node_id: &str, ) -> Result<HashMap<String, Arc<StaticNode>>, String>

Get child nodes for a parent node, keyed by alias. Default implementation derives from get_edges() and get_nodes().

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§