pub struct GraphModelAccess { /* private fields */ }Expand description
ModelAccess implementation built from a StaticGraph.
Indices are lazily built on first access via [ensure_built] and
stored as Arc-wrapped maps for cheap cloning.
§Construction
GraphModelAccess::new— lazy, caches built on firstensure_built()callGraphModelAccess::new_eager— builds caches immediatelyGraphModelAccess::from_graph— backward-compat eager constructor
Implementations§
Source§impl GraphModelAccess
impl GraphModelAccess
Sourcepub fn new(graph: Arc<StaticGraph>, default_allow: bool) -> Self
pub fn new(graph: Arc<StaticGraph>, default_allow: bool) -> Self
Create a new lazy GraphModelAccess. Caches are not built until
[ensure_built] is called (or a mutable accessor triggers it).
Sourcepub fn new_eager(graph: Arc<StaticGraph>, default_allow: bool) -> Self
pub fn new_eager(graph: Arc<StaticGraph>, default_allow: bool) -> Self
Create a GraphModelAccess with caches built immediately.
Sourcepub fn from_graph(graph: &StaticGraph) -> Self
pub fn from_graph(graph: &StaticGraph) -> Self
Backward-compatible eager constructor from a borrowed StaticGraph.
Sourcepub fn ensure_built(&mut self) -> Result<(), String>
pub fn ensure_built(&mut self) -> Result<(), String>
Ensure all caches are built. No-op if already built.
Sourcepub fn invalidate_caches(&mut self)
pub fn invalidate_caches(&mut self)
Clear all cached indices. The next call to [ensure_built] will rebuild.
Sourcepub fn get_nodes_internal(&self) -> Option<&HashMap<String, Arc<StaticNode>>>
pub fn get_nodes_internal(&self) -> Option<&HashMap<String, Arc<StaticNode>>>
Get nodes by ID (returns None if caches not built).
Sourcepub fn get_nodes_by_alias_internal(
&self,
) -> Option<&HashMap<String, Arc<StaticNode>>>
pub fn get_nodes_by_alias_internal( &self, ) -> Option<&HashMap<String, Arc<StaticNode>>>
Get nodes by alias (returns None if caches not built).
Sourcepub fn get_edges_internal(&self) -> Option<&HashMap<String, Vec<String>>>
pub fn get_edges_internal(&self) -> Option<&HashMap<String, Vec<String>>>
Get edges (returns None if caches not built).
Sourcepub fn get_reverse_edges_internal(
&self,
) -> Option<&HashMap<String, Vec<String>>>
pub fn get_reverse_edges_internal( &self, ) -> Option<&HashMap<String, Vec<String>>>
Get reverse edges (returns None if caches not built).
Sourcepub fn get_nodes_by_nodegroup_internal(
&self,
) -> Option<&HashMap<String, Vec<Arc<StaticNode>>>>
pub fn get_nodes_by_nodegroup_internal( &self, ) -> Option<&HashMap<String, Vec<Arc<StaticNode>>>>
Get nodes grouped by nodegroup (returns None if caches not built).
Sourcepub fn get_nodegroups_internal(
&self,
) -> Option<&HashMap<String, Arc<StaticNodegroup>>>
pub fn get_nodegroups_internal( &self, ) -> Option<&HashMap<String, Arc<StaticNodegroup>>>
Get nodegroups by ID (returns None if caches not built).
pub fn get_nodes_arc(&self) -> Option<Arc<HashMap<String, Arc<StaticNode>>>>
pub fn get_nodes_by_alias_arc( &self, ) -> Option<Arc<HashMap<String, Arc<StaticNode>>>>
pub fn get_edges_arc(&self) -> Option<Arc<HashMap<String, Vec<String>>>>
pub fn get_reverse_edges_arc(&self) -> Option<Arc<HashMap<String, Vec<String>>>>
pub fn get_nodes_by_nodegroup_arc( &self, ) -> Option<Arc<HashMap<String, Vec<Arc<StaticNode>>>>>
pub fn get_nodegroups_arc( &self, ) -> Option<Arc<HashMap<String, Arc<StaticNodegroup>>>>
Sourcepub fn get_node_objects(
&mut self,
) -> Result<&HashMap<String, Arc<StaticNode>>, String>
pub fn get_node_objects( &mut self, ) -> Result<&HashMap<String, Arc<StaticNode>>, String>
Get nodes, building caches if needed.
Sourcepub fn get_node_objects_by_alias(
&mut self,
) -> Result<&HashMap<String, Arc<StaticNode>>, String>
pub fn get_node_objects_by_alias( &mut self, ) -> Result<&HashMap<String, Arc<StaticNode>>, String>
Get nodes by alias, building caches if needed.
Sourcepub fn get_edges(&mut self) -> Result<&HashMap<String, Vec<String>>, String>
pub fn get_edges(&mut self) -> Result<&HashMap<String, Vec<String>>, String>
Get edges, building caches if needed.
Sourcepub fn get_nodegroup_objects(
&mut self,
) -> Result<&HashMap<String, Arc<StaticNodegroup>>, String>
pub fn get_nodegroup_objects( &mut self, ) -> Result<&HashMap<String, Arc<StaticNodegroup>>, String>
Get nodegroups, building caches if needed.
Sourcepub fn get_root_node_mut(&mut self) -> Result<Arc<StaticNode>, String>
pub fn get_root_node_mut(&mut self) -> Result<Arc<StaticNode>, String>
Get root node, building caches if needed.
Sourcepub fn get_child_nodes_mut(
&mut self,
node_id: &str,
) -> Result<HashMap<String, Arc<StaticNode>>, String>
pub fn get_child_nodes_mut( &mut self, node_id: &str, ) -> Result<HashMap<String, Arc<StaticNode>>, String>
Get child nodes for a given node, building caches if needed.
Sourcepub fn get_child_nodes(&self, node_id: &str) -> HashMap<String, Arc<StaticNode>>
pub fn get_child_nodes(&self, node_id: &str) -> HashMap<String, Arc<StaticNode>>
Get child nodes from already-built caches. Returns empty map if caches not built.
Sourcepub fn get_nodes_by_alias(&self) -> Option<&HashMap<String, Arc<StaticNode>>>
pub fn get_nodes_by_alias(&self) -> Option<&HashMap<String, Arc<StaticNode>>>
Get nodes indexed by alias (requires caches already built).
Sourcepub fn get_graph(&self) -> &StaticGraph
pub fn get_graph(&self) -> &StaticGraph
Get a reference to the underlying graph.
Sourcepub fn get_graph_arc(&self) -> Arc<StaticGraph>
pub fn get_graph_arc(&self) -> Arc<StaticGraph>
Get an Arc clone of the underlying graph.
Sourcepub fn get_default_allow(&self) -> bool
pub fn get_default_allow(&self) -> bool
Get the default_allow setting.
Sourcepub fn set_graph(&mut self, graph: Arc<StaticGraph>)
pub fn set_graph(&mut self, graph: Arc<StaticGraph>)
Replace the graph and invalidate all caches.
Sourcepub fn set_graph_nodes(&mut self, nodes: Vec<StaticNode>)
pub fn set_graph_nodes(&mut self, nodes: Vec<StaticNode>)
Replace graph nodes and invalidate caches.
Sourcepub fn set_graph_edges(&mut self, edges: Vec<StaticEdge>)
pub fn set_graph_edges(&mut self, edges: Vec<StaticEdge>)
Replace graph edges and invalidate caches.
Sourcepub fn set_graph_nodegroups(&mut self, nodegroups: Vec<StaticNodegroup>)
pub fn set_graph_nodegroups(&mut self, nodegroups: Vec<StaticNodegroup>)
Replace graph nodegroups and invalidate caches.
Sourcepub fn rebuild_from_graph(&mut self, graph: &StaticGraph)
pub fn rebuild_from_graph(&mut self, graph: &StaticGraph)
Rebuild indices from a new graph, preserving permissions.
Sourcepub fn set_permitted_nodegroups_rules(
&mut self,
permissions: HashMap<String, PermissionRule>,
)
pub fn set_permitted_nodegroups_rules( &mut self, permissions: HashMap<String, PermissionRule>, )
Set permitted nodegroups with full PermissionRule support.
Sourcepub fn set_permitted_nodegroups_bool(
&mut self,
permissions: HashMap<String, bool>,
)
pub fn set_permitted_nodegroups_bool( &mut self, permissions: HashMap<String, bool>, )
Set permitted nodegroups from boolean map (backward compatibility).
Sourcepub fn set_default_allow(&mut self, default_allow: bool)
pub fn set_default_allow(&mut self, default_allow: bool)
Set the default permission for nodegroups not explicitly listed.
Sourcepub fn is_nodegroup_permitted(&self, nodegroup_id: &str) -> bool
pub fn is_nodegroup_permitted(&self, nodegroup_id: &str) -> bool
Check if a nodegroup is permitted. Conditional rules return true (nodegroup permitted, tiles filtered separately).
Sourcepub fn is_tile_permitted(&self, tile: &StaticTile) -> bool
pub fn is_tile_permitted(&self, tile: &StaticTile) -> bool
Check if a specific tile is permitted by its nodegroup’s permission rule.
Sourcepub fn get_permission_rule(&self, nodegroup_id: &str) -> Option<&PermissionRule>
pub fn get_permission_rule(&self, nodegroup_id: &str) -> Option<&PermissionRule>
Get the permission rule for a nodegroup.
Sourcepub fn get_permitted_nodegroups_bool(&self) -> HashMap<String, bool>
pub fn get_permitted_nodegroups_bool(&self) -> HashMap<String, bool>
Get permitted nodegroups as a boolean map (for backward compat).
Sourcepub fn get_permitted_nodegroups_rules(&self) -> &HashMap<String, PermissionRule>
pub fn get_permitted_nodegroups_rules(&self) -> &HashMap<String, PermissionRule>
Get all permission rules.
Trait Implementations§
Source§impl Clone for GraphModelAccess
impl Clone for GraphModelAccess
Source§fn clone(&self) -> GraphModelAccess
fn clone(&self) -> GraphModelAccess
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl ModelAccess for GraphModelAccess
impl ModelAccess for GraphModelAccess
Source§fn get_edges(&self) -> Option<&HashMap<String, Vec<String>>>
fn get_edges(&self) -> Option<&HashMap<String, Vec<String>>>
Source§fn get_reverse_edges(&self) -> Option<&HashMap<String, Vec<String>>>
fn get_reverse_edges(&self) -> Option<&HashMap<String, Vec<String>>>
Source§fn get_nodes_by_nodegroup(
&self,
) -> Option<&HashMap<String, Vec<Arc<StaticNode>>>>
fn get_nodes_by_nodegroup( &self, ) -> Option<&HashMap<String, Vec<Arc<StaticNode>>>>
Source§fn get_nodegroups(&self) -> Option<&HashMap<String, Arc<StaticNodegroup>>>
fn get_nodegroups(&self) -> Option<&HashMap<String, Arc<StaticNodegroup>>>
Source§fn get_root_node(&self) -> Result<Arc<StaticNode>, String>
fn get_root_node(&self) -> Result<Arc<StaticNode>, String>
istopnode, with fallback to
scanning for nodes with no nodegroup_id.Source§fn get_permitted_nodegroups(&self) -> HashMap<String, PermissionRule>
fn get_permitted_nodegroups(&self) -> HashMap<String, PermissionRule>
Source§fn get_child_nodes(
&self,
node_id: &str,
) -> Result<HashMap<String, Arc<StaticNode>>, String>
fn get_child_nodes( &self, node_id: &str, ) -> Result<HashMap<String, Arc<StaticNode>>, String>
get_edges() and get_nodes().