Skip to main content

StaticResourceRegistry

Struct StaticResourceRegistry 

Source
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

Source

pub fn new() -> Self

Create an empty registry

Source

pub fn get_graph_id(&self, resource_id: &str) -> Option<&str>

Get the graph_id for a resource

Source

pub fn get(&self, resource_id: &str) -> Option<&ResourceEntry>

Get the entry for a resource

Source

pub fn get_mut(&mut self, resource_id: &str) -> Option<&mut ResourceEntry>

Get a mutable entry for a resource

Source

pub fn get_full(&self, resource_id: &str) -> Option<&StaticResource>

Get the full resource if available (returns None if only summary stored)

Source

pub fn get_summary(&self, resource_id: &str) -> Option<StaticResourceSummary>

Get a summary for a resource (works for both summary and full entries)

Source

pub fn contains(&self, resource_id: &str) -> bool

Check if a resource is known

Source

pub fn has_full(&self, resource_id: &str) -> bool

Check if a resource has full data with tiles

Source

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.

Source

pub fn memory_stats_detailed(&self) -> RegistryMemoryStats

Expensive version that estimates byte sizes by re-serializing. Call once, not in a loop.

Source

pub fn len(&self) -> usize

Number of resources in the registry

Source

pub fn is_empty(&self) -> bool

Check if registry is empty

Source

pub fn insert_summary(&mut self, summary: StaticResourceSummary)

Add a single resource summary (won’t overwrite full resources)

Source

pub fn insert(&mut self, summary: StaticResourceSummary)

Add a single resource summary (legacy alias for insert_summary)

Source

pub fn insert_full(&mut self, resource: StaticResource)

Add a full resource (always overwrites, as it’s more complete)

Source

pub fn upgrade_to_full(&mut self, resource: StaticResource)

Upgrade a summary to a full resource (if the resource exists)

Source

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
Source

pub fn iter(&self) -> impl Iterator<Item = (&String, &ResourceEntry)>

Iterate over all entries

Source

pub fn iter_full(&self) -> impl Iterator<Item = (&String, &StaticResource)>

Iterate over all full resources

Source

pub fn ids(&self) -> impl Iterator<Item = &String>

Get all resource IDs

Source

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.

Source

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 lookup
  • node_identifier - Node alias or node ID to extract values for
§Returns
  • Ok(HashMap<String, Vec<Value>>) - Map from resource_id to list of values
  • Err(String) - Error if node not found
Source

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 lookup
  • node_identifier - Node alias or node ID to extract values for
  • flatten_localized - If true, extract string from localized values {“en”: “value”}
§Returns
  • Ok(HashMap<String, Vec<String>>) - Map from display value to list of resource_ids
  • Err(String) - Error if node not found
Source

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 lookup
  • node_identifier - Node alias or node ID to extract values for
  • flatten_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_ids
  • Err(String) - Error if node not found
Source

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 lookup
  • filter_node - Alias or ID of the node to filter on
  • filter_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 extract
  • flatten_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

Source§

fn clone(&self) -> StaticResourceRegistry

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 Debug for StaticResourceRegistry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for StaticResourceRegistry

Source§

fn default() -> StaticResourceRegistry

Returns the “default value” for a type. Read more
Source§

impl ResourceDisplayResolver for StaticResourceRegistry

Source§

fn resolve_resource_display( &self, resource_id: &str, _language: &str, ) -> Option<String>

Resolve a resource instance UUID to its display name. Read more

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.