pub struct StaticResourceRegistry { /* private fields */ }Expand description
In-memory registry of resources for relationship resolution and caching
Stores either full resources or summaries, allowing memory-efficient storage when only metadata is needed, with the ability to upgrade to full resources when tiles are required.
Used to:
- Look up graph_id for referenced resources
- Populate __cache on resources with related resource summaries
- Enrich resource-instance tile data with ontologyProperty from node config
- Cache full resources for traversal (like staticStore)
Implementations§
Source§impl StaticResourceRegistry
impl StaticResourceRegistry
Sourcepub fn get_graph_id(&self, resource_id: &str) -> Option<&str>
pub fn get_graph_id(&self, resource_id: &str) -> Option<&str>
Get the graph_id for a resource
Sourcepub fn get(&self, resource_id: &str) -> Option<&ResourceEntry>
pub fn get(&self, resource_id: &str) -> Option<&ResourceEntry>
Get the entry for a resource
Sourcepub fn get_mut(&mut self, resource_id: &str) -> Option<&mut ResourceEntry>
pub fn get_mut(&mut self, resource_id: &str) -> Option<&mut ResourceEntry>
Get a mutable entry for a resource
Sourcepub fn get_full(&self, resource_id: &str) -> Option<&StaticResource>
pub fn get_full(&self, resource_id: &str) -> Option<&StaticResource>
Get the full resource if available (returns None if only summary stored)
Sourcepub fn get_summary(&self, resource_id: &str) -> Option<StaticResourceSummary>
pub fn get_summary(&self, resource_id: &str) -> Option<StaticResourceSummary>
Get a summary for a resource (works for both summary and full entries)
Sourcepub fn memory_stats(&self) -> RegistryMemoryStats
pub fn memory_stats(&self) -> RegistryMemoryStats
Get a breakdown of registry contents for memory diagnostics.
Returns (total_entries, full_count, summary_count, total_tiles, total_cache_bytes) where total_cache_bytes is an estimate of serialized __cache JSON size.
Sourcepub fn memory_stats_detailed(&self) -> RegistryMemoryStats
pub fn memory_stats_detailed(&self) -> RegistryMemoryStats
Expensive version that estimates byte sizes by re-serializing. Call once, not in a loop.
Sourcepub fn insert_summary(&mut self, summary: StaticResourceSummary)
pub fn insert_summary(&mut self, summary: StaticResourceSummary)
Add a single resource summary (won’t overwrite full resources)
Sourcepub fn insert(&mut self, summary: StaticResourceSummary)
pub fn insert(&mut self, summary: StaticResourceSummary)
Add a single resource summary (legacy alias for insert_summary)
Sourcepub fn insert_full(&mut self, resource: StaticResource)
pub fn insert_full(&mut self, resource: StaticResource)
Add a full resource (always overwrites, as it’s more complete)
Sourcepub fn upgrade_to_full(&mut self, resource: StaticResource)
pub fn upgrade_to_full(&mut self, resource: StaticResource)
Upgrade a summary to a full resource (if the resource exists)
Sourcepub fn merge_from_resources(
&mut self,
resources: &[StaticResource],
store_full: bool,
include_caches: bool,
)
pub fn merge_from_resources( &mut self, resources: &[StaticResource], store_full: bool, include_caches: bool, )
Merge resources into registry
- If store_full is true, stores full resources (for traversal)
- If store_full is false, stores only summaries (memory efficient)
- If include_caches is true, also merges any __cache.relatedResources as summaries
Sourcepub fn iter(&self) -> impl Iterator<Item = (&String, &ResourceEntry)>
pub fn iter(&self) -> impl Iterator<Item = (&String, &ResourceEntry)>
Iterate over all entries
Sourcepub fn iter_full(&self) -> impl Iterator<Item = (&String, &StaticResource)>
pub fn iter_full(&self) -> impl Iterator<Item = (&String, &StaticResource)>
Iterate over all full resources
Sourcepub fn populate_caches(
&self,
resources: &mut [StaticResource],
graph: &StaticGraph,
enrich_relationships: bool,
strict: bool,
recompute_descriptors: bool,
) -> Result<PopulateCachesResult, String>
pub fn populate_caches( &self, resources: &mut [StaticResource], graph: &StaticGraph, enrich_relationships: bool, strict: bool, recompute_descriptors: bool, ) -> Result<PopulateCachesResult, String>
Populate __cache on resources with summaries for referenced resources
Uses the graph to identify resource-instance/resource-instance-list nodes, then populates cache entries for each referenced resource.
If enrich_relationships is true, also adds ontologyProperty/inverseOntologyProperty
to tile data based on node config and the target resource’s graph.
Returns information about unknown references found during processing.
Sourcepub fn get_node_values_index(
&self,
graph: &StaticGraph,
node_identifier: &str,
) -> Result<HashMap<String, Vec<Value>>, String>
pub fn get_node_values_index( &self, graph: &StaticGraph, node_identifier: &str, ) -> Result<HashMap<String, Vec<Value>>, String>
Build an index from resource IDs to node values for a given node.
Efficiently iterates through tiles, filtering by nodegroup and extracting values for the specified node.
§Arguments
graph- The graph to use for node lookupnode_identifier- Node alias or node ID to extract values for
§Returns
Ok(HashMap<String, Vec<Value>>)- Map from resource_id to list of valuesErr(String)- Error if node not found
Sourcepub fn get_value_to_resources_index(
&self,
graph: &StaticGraph,
node_identifier: &str,
flatten_localized: bool,
) -> Result<HashMap<String, Vec<String>>, String>
pub fn get_value_to_resources_index( &self, graph: &StaticGraph, node_identifier: &str, flatten_localized: bool, ) -> Result<HashMap<String, Vec<String>>, String>
Build an inverted index from node display values to resource IDs.
Uses the type serialization infrastructure to extract display strings, which handles built-in types (string, concept, domain-value, etc.) and extension-registered types (reference, etc.) via the global registry.
§Arguments
graph- The graph to use for node lookupnode_identifier- Node alias or node ID to extract values forflatten_localized- If true, extract string from localized values {“en”: “value”}
§Returns
Ok(HashMap<String, Vec<String>>)- Map from display value to list of resource_idsErr(String)- Error if node not found
Sourcepub fn get_value_to_resources_index_with_context(
&self,
graph: &StaticGraph,
node_identifier: &str,
flatten_localized: bool,
ctx: Option<&SerializationContext<'_>>,
) -> Result<HashMap<String, Vec<String>>, String>
pub fn get_value_to_resources_index_with_context( &self, graph: &StaticGraph, node_identifier: &str, flatten_localized: bool, ctx: Option<&SerializationContext<'_>>, ) -> Result<HashMap<String, Vec<String>>, String>
Build an inverted index from node display values to resource IDs, with an explicit serialization context for resolvers and extensions.
§Arguments
graph- The graph to use for node lookupnode_identifier- Node alias or node ID to extract values forflatten_localized- If true, extract string from localized values {“en”: “value”}ctx- Optional serialization context (resolvers, extension registry)
§Returns
Ok(HashMap<String, Vec<String>>)- Map from display value to list of resource_idsErr(String)- Error if node not found
Sourcepub fn get_filtered_tile_values(
&self,
graph: &StaticGraph,
filter_node: &str,
filter_values: &[&str],
extract_node: &str,
flatten_localized: bool,
ctx: Option<&SerializationContext<'_>>,
required_scope: Option<&str>,
) -> Result<Vec<Value>, String>
pub fn get_filtered_tile_values( &self, graph: &StaticGraph, filter_node: &str, filter_values: &[&str], extract_node: &str, flatten_localized: bool, ctx: Option<&SerializationContext<'_>>, required_scope: Option<&str>, ) -> Result<Vec<Value>, String>
Extract values from one node in tiles where another node matches a filter.
Both nodes must be in the same nodegroup. For each tile in that nodegroup,
the filter node’s display value is checked against filter_values. If any
filter value appears in the display string, the extract node’s raw JSON
value is included in the results.
§Arguments
graph- The graph for node lookupfilter_node- Alias or ID of the node to filter onfilter_values- Display values that pass the filter (matched as substrings of comma-separated tags)extract_node- Alias or ID of the node whose values to extractflatten_localized- If true, flatten localized values for the filter node
§Returns
A Vec<serde_json::Value> of raw values from the extract node for matching tiles.
Trait Implementations§
Source§impl Clone for StaticResourceRegistry
impl Clone for StaticResourceRegistry
Source§fn clone(&self) -> StaticResourceRegistry
fn clone(&self) -> StaticResourceRegistry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more