Skip to main content

GraphModelAccess

Struct GraphModelAccess 

Source
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

Implementations§

Source§

impl GraphModelAccess

Source

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).

Source

pub fn new_eager(graph: Arc<StaticGraph>, default_allow: bool) -> Self

Create a GraphModelAccess with caches built immediately.

Source

pub fn from_graph(graph: &StaticGraph) -> Self

Backward-compatible eager constructor from a borrowed StaticGraph.

Source

pub fn ensure_built(&mut self) -> Result<(), String>

Ensure all caches are built. No-op if already built.

Source

pub fn is_built(&self) -> bool

Returns true if caches have been built.

Source

pub fn invalidate_caches(&mut self)

Clear all cached indices. The next call to [ensure_built] will rebuild.

Source

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

Get nodes by ID (returns None if caches not built).

Source

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

Get nodes by alias (returns None if caches not built).

Source

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

Get edges (returns None if caches not built).

Source

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

Get reverse edges (returns None if caches not built).

Source

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).

Source

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

Get nodegroups by ID (returns None if caches not built).

Source

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

Source

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

Source

pub fn get_edges_arc(&self) -> Option<Arc<HashMap<String, Vec<String>>>>

Source

pub fn get_reverse_edges_arc(&self) -> Option<Arc<HashMap<String, Vec<String>>>>

Source

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

Source

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

Source

pub fn get_node_objects( &mut self, ) -> Result<&HashMap<String, Arc<StaticNode>>, String>

Get nodes, building caches if needed.

Source

pub fn get_node_objects_by_alias( &mut self, ) -> Result<&HashMap<String, Arc<StaticNode>>, String>

Get nodes by alias, building caches if needed.

Source

pub fn get_edges(&mut self) -> Result<&HashMap<String, Vec<String>>, String>

Get edges, building caches if needed.

Source

pub fn get_nodegroup_objects( &mut self, ) -> Result<&HashMap<String, Arc<StaticNodegroup>>, String>

Get nodegroups, building caches if needed.

Source

pub fn get_root_node_mut(&mut self) -> Result<Arc<StaticNode>, String>

Get root node, building caches if needed.

Source

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.

Source

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.

Source

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

Get nodes indexed by alias (requires caches already built).

Source

pub fn get_graph(&self) -> &StaticGraph

Get a reference to the underlying graph.

Source

pub fn get_graph_arc(&self) -> Arc<StaticGraph>

Get an Arc clone of the underlying graph.

Source

pub fn get_default_allow(&self) -> bool

Get the default_allow setting.

Source

pub fn set_graph(&mut self, graph: Arc<StaticGraph>)

Replace the graph and invalidate all caches.

Source

pub fn set_graph_nodes(&mut self, nodes: Vec<StaticNode>)

Replace graph nodes and invalidate caches.

Source

pub fn set_graph_edges(&mut self, edges: Vec<StaticEdge>)

Replace graph edges and invalidate caches.

Source

pub fn set_graph_nodegroups(&mut self, nodegroups: Vec<StaticNodegroup>)

Replace graph nodegroups and invalidate caches.

Source

pub fn rebuild_from_graph(&mut self, graph: &StaticGraph)

Rebuild indices from a new graph, preserving permissions.

Source

pub fn set_permitted_nodegroups_rules( &mut self, permissions: HashMap<String, PermissionRule>, )

Set permitted nodegroups with full PermissionRule support.

Source

pub fn set_permitted_nodegroups_bool( &mut self, permissions: HashMap<String, bool>, )

Set permitted nodegroups from boolean map (backward compatibility).

Source

pub fn set_default_allow(&mut self, default_allow: bool)

Set the default permission for nodegroups not explicitly listed.

Source

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).

Source

pub fn is_tile_permitted(&self, tile: &StaticTile) -> bool

Check if a specific tile is permitted by its nodegroup’s permission rule.

Source

pub fn get_permission_rule(&self, nodegroup_id: &str) -> Option<&PermissionRule>

Get the permission rule for a nodegroup.

Source

pub fn get_permitted_nodegroups_bool(&self) -> HashMap<String, bool>

Get permitted nodegroups as a boolean map (for backward compat).

Source

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

Get all permission rules.

Source

pub fn prune_graph( &mut self, keep_functions: Option<&[String]>, ) -> Result<(), String>

Prune graph to only include permitted nodegroups and their dependencies. Updates the graph and rebuilds caches.

Trait Implementations§

Source§

impl Clone for GraphModelAccess

Source§

fn clone(&self) -> GraphModelAccess

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 ModelAccess for GraphModelAccess

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_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_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.
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().

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.