pub struct EntityGraph { /* private fields */ }Expand description
Core entity graph with bitmap tag indexing and bidirectional ref adjacency.
Implementations§
Source§impl EntityGraph
impl EntityGraph
Sourcepub fn with_namespace(ns: DefNamespace) -> Self
pub fn with_namespace(ns: DefNamespace) -> Self
Create an entity graph with an ontology namespace.
Sourcepub fn add(&mut self, entity: HDict) -> Result<String, GraphError>
pub fn add(&mut self, entity: HDict) -> Result<String, GraphError>
Add an entity to the graph.
The entity must have an id tag that is a Ref. Returns the ref
value string on success.
Sourcepub fn update(
&mut self,
ref_val: &str,
changes: HDict,
) -> Result<(), GraphError>
pub fn update( &mut self, ref_val: &str, changes: HDict, ) -> Result<(), GraphError>
Update an existing entity by merging changes into it.
Tags in changes overwrite existing tags; Kind::Remove tags are
deleted. The id tag cannot be changed.
Sourcepub fn remove(&mut self, ref_val: &str) -> Result<HDict, GraphError>
pub fn remove(&mut self, ref_val: &str) -> Result<HDict, GraphError>
Remove an entity from the graph. Returns the removed entity.
Sourcepub fn read(&self, filter_expr: &str, limit: usize) -> Result<HGrid, GraphError>
pub fn read(&self, filter_expr: &str, limit: usize) -> Result<HGrid, GraphError>
Run a filter expression and return matching entities as a grid.
Sourcepub fn read_all(
&self,
filter_expr: &str,
limit: usize,
) -> Result<Vec<&HDict>, GraphError>
pub fn read_all( &self, filter_expr: &str, limit: usize, ) -> Result<Vec<&HDict>, GraphError>
Run a filter expression and return matching entities as references.
Sourcepub fn refs_from(&self, ref_val: &str, ref_type: Option<&str>) -> Vec<String>
pub fn refs_from(&self, ref_val: &str, ref_type: Option<&str>) -> Vec<String>
Get ref values that the given entity points to.
Sourcepub fn refs_to(&self, ref_val: &str, ref_type: Option<&str>) -> Vec<String>
pub fn refs_to(&self, ref_val: &str, ref_type: Option<&str>) -> Vec<String>
Get ref values of entities that point to the given entity.
Sourcepub fn entities_fitting(&self, spec_name: &str) -> Vec<&HDict>
pub fn entities_fitting(&self, spec_name: &str) -> Vec<&HDict>
Find all entities that structurally fit a spec/type name.
Requires a namespace to be set. Returns empty if no namespace.
Sourcepub fn validate(&self) -> Vec<ValidationIssue>
pub fn validate(&self) -> Vec<ValidationIssue>
Validate all entities against the namespace and check for dangling refs.
Returns empty if no namespace is set and no dangling refs exist.
Sourcepub fn to_grid(&self, filter_expr: &str) -> Result<HGrid, GraphError>
pub fn to_grid(&self, filter_expr: &str) -> Result<HGrid, GraphError>
Convert matching entities to a grid.
If filter_expr is empty, exports all entities.
Otherwise, delegates to read.
Sourcepub fn from_grid(
grid: &HGrid,
namespace: Option<DefNamespace>,
) -> Result<Self, GraphError>
pub fn from_grid( grid: &HGrid, namespace: Option<DefNamespace>, ) -> Result<Self, GraphError>
Build an EntityGraph from a grid.
Rows without a valid id Ref tag are silently skipped.
Sourcepub fn changes_since(&self, version: u64) -> &[GraphDiff]
pub fn changes_since(&self, version: u64) -> &[GraphDiff]
Get changelog entries since a given version.