Skip to main content

ResourceInstanceWrapperCore

Struct ResourceInstanceWrapperCore 

Source
pub struct ResourceInstanceWrapperCore {
    pub graph_id: String,
    pub resource_instance: Option<StaticResourceMetadata>,
    pub tiles: Option<HashMap<String, StaticTile>>,
    pub nodegroup_index: HashMap<String, Vec<String>>,
    pub loaded_nodegroups: Arc<Mutex<HashMap<String, LoadState>>>,
    pub pseudo_cache: Arc<Mutex<HashMap<String, PseudoListCore>>>,
    pub cached_nodes: Option<Arc<HashMap<String, Arc<StaticNode>>>>,
    pub cached_edges: Option<Arc<HashMap<String, Vec<String>>>>,
    pub cached_reverse_edges: Option<Arc<HashMap<String, Vec<String>>>>,
    pub cached_nodes_by_nodegroup: Option<Arc<HashMap<String, Vec<Arc<StaticNode>>>>>,
    pub cached_nodegroups: Option<Arc<HashMap<String, Arc<StaticNodegroup>>>>,
}
Expand description

Core resource instance wrapper - platform-agnostic business logic

Contains all tile storage, indexing, and business logic. Used by NAPI and Python bindings. WASM has a parallel copy in alizarin-wasm::instance_wrapper::ResourceInstanceWrapperCore that uses Rc instead of Arc.

TODO(priority): Unify the WASM copy with this struct so methods like set_tile_data_for_node don’t need to be maintained in two places.

Fields§

§graph_id: String

Graph ID to look up model

§resource_instance: Option<StaticResourceMetadata>

Resource metadata

§tiles: Option<HashMap<String, StaticTile>>

Tile storage (tileid -> tile)

§nodegroup_index: HashMap<String, Vec<String>>

Index: nodegroup_id -> list of tile_ids

§loaded_nodegroups: Arc<Mutex<HashMap<String, LoadState>>>

Track which nodegroups have been loaded/loading

§pseudo_cache: Arc<Mutex<HashMap<String, PseudoListCore>>>

Cache of PseudoValues (alias -> PseudoListCore)

§cached_nodes: Option<Arc<HashMap<String, Arc<StaticNode>>>>

Cached model indices - avoids repeated lookups

§cached_edges: Option<Arc<HashMap<String, Vec<String>>>>§cached_reverse_edges: Option<Arc<HashMap<String, Vec<String>>>>§cached_nodes_by_nodegroup: Option<Arc<HashMap<String, Vec<Arc<StaticNode>>>>>§cached_nodegroups: Option<Arc<HashMap<String, Arc<StaticNodegroup>>>>

Implementations§

Source§

impl ResourceInstanceWrapperCore

Source

pub fn new(graph_id: String) -> Self

Create a new empty core with just a graph ID

Source

pub fn set_cached_indices(&mut self, model: &dyn ModelAccess)

Set cached model indices from a ModelAccess implementation

Source

pub fn load_tiles(&mut self, tiles: Vec<StaticTile>)

Load tiles into the wrapper

Source

pub fn get_tile(&self, tile_id: &str) -> Option<&StaticTile>

Get a tile by ID

Source

pub fn set_tile_data_for_node( &mut self, tile_id: &str, node_id: &str, value: Value, ) -> bool

Set a single node’s data in a tile, mutating in place. Returns true if the tile was found and updated, false otherwise.

Source

pub fn get_tiles_for_nodegroup(&self, nodegroup_id: &str) -> Vec<&StaticTile>

Get tiles for a nodegroup

Source

pub fn is_nodegroup_loaded(&self, nodegroup_id: &str) -> bool

Check if a nodegroup is loaded

Source

pub fn mark_nodegroup_loaded(&self, nodegroup_id: &str)

Mark a nodegroup as loaded

Source

pub fn get_cached_pseudo(&self, alias: &str) -> Option<PseudoListCore>

Get a cached pseudo list by alias

Source

pub fn store_pseudo(&self, alias: String, pseudo_list: PseudoListCore)

Store a pseudo list in the cache

Source

pub fn values_from_resource_nodegroup( &self, existing_values: &HashMap<String, Option<bool>>, nodegroup_tile_ids: &[String], nodegroup_id: &str, model: &dyn ModelAccess, ) -> Result<ValuesFromNodegroupResult, SemanticChildError>

Build pseudo values from tiles for a nodegroup.

Delegates to the standalone values_from_resource_nodegroup function, passing this wrapper’s tile store.

Source

pub fn ensure_nodegroup( &self, all_values_map: &HashMap<String, Option<bool>>, all_nodegroups: &mut HashMap<String, bool>, nodegroup_id: &str, add_if_missing: bool, nodegroup_permissions: &HashMap<String, PermissionRule>, do_implied_nodegroups: bool, model: &dyn ModelAccess, ) -> Result<EnsureNodegroupResult, SemanticChildError>

Process a single nodegroup and return structured values.

Delegates to the standalone ensure_nodegroup function, passing this wrapper’s tile store.

Source

pub fn populate( &self, lazy: bool, nodegroup_ids: &[String], root_node_alias: &str, model: &dyn ModelAccess, ) -> Result<PopulateResult, SemanticChildError>

Main populate implementation

Orchestrates loading all nodegroups for a resource.

Source

pub fn get_semantic_child_value( &self, parent_tile_id: Option<&String>, parent_node_id: &str, parent_nodegroup_id: Option<&String>, child_alias: &str, model: &dyn ModelAccess, ) -> Result<SemanticChildResult, SemanticChildError>

Get semantic child values for a given parent node and child alias

Source

pub fn resolve_path( &self, path: &str, model: &dyn ModelAccess, ) -> Result<PathResolutionInfo, PathError>

Resolve a dot-separated path through the graph model.

Walks the graph edges matching node aliases at each segment, returning the target node’s metadata and nodegroup ID.

Source

pub fn resolve_and_filter_tiles( &self, path: &str, model: &dyn ModelAccess, filter_tile_id: Option<&str>, ) -> Result<(PathResolutionInfo, Vec<StaticTile>), PathError>

Resolve a path and return the resolution info plus matching tiles.

Delegates to the standalone resolve_and_filter_tiles function, passing this wrapper’s tile store and nodegroup index.

Source

pub fn get_values_at_path( &self, path: &str, model: &dyn ModelAccess, filter_tile_id: Option<&str>, ) -> Result<PseudoListCore, PathError>

Resolve a dot-separated path and return a PseudoListCore for the target node.

This is the main entry point for path-based value access. It walks the graph model to find the target node, then retrieves matching tiles from the store and builds a PseudoListCore — all without materializing the full tree.

If filter_tile_id is provided, only tiles that match the parent-child relationship for that tile are included (using matches_semantic_child).

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