pub struct EntityRegistry { /* private fields */ }Expand description
Scope-aware in-memory entity registry.
Entities are partitioned by scope. Resolution first tries the exact scope,
then falls back to namespace-only scope if the exact scope yields nothing.
Cross-scope collisions are avoided by using ScopeKey in all indexes.
This registry owns entity data as a derived projection — it does NOT own source truth. Entities can be rebuilt from upstream stores.
Implementations§
Source§impl EntityRegistry
impl EntityRegistry
Sourcepub fn new(max_aliases: usize, max_entities: usize) -> Self
pub fn new(max_aliases: usize, max_entities: usize) -> Self
Create a new registry with bounded alias and entity limits.
Sourcepub fn register(&mut self, entity: Entity) -> Result<(), RuntimeError>
pub fn register(&mut self, entity: Entity) -> Result<(), RuntimeError>
Register a new entity. Returns error if the registry is full.
Sourcepub fn resolve(&self, mention: &str, scope: &ScopeKey) -> ResolveResult
pub fn resolve(&self, mention: &str, scope: &ScopeKey) -> ResolveResult
Resolve a raw mention within a specific scope.
Resolution order:
- Exact canonical name match in the given scope ->
ExactCanonical - Exact alias match in the given scope ->
ExactAlias - Namespace-only fallback (if scope has more dimensions) ->
ScopedFallback - Unresolved
Alternatives from other scopes with the same namespace are included
in ResolveResult::alternatives when the primary match is Unresolved
or ScopedFallback, so callers can see potential ambiguity.
Sourcepub fn iter_scope<'a>(
&'a self,
scope: &'a ScopeKey,
) -> impl Iterator<Item = &'a Entity> + 'a
pub fn iter_scope<'a>( &'a self, scope: &'a ScopeKey, ) -> impl Iterator<Item = &'a Entity> + 'a
Iterate over entities in a specific scope.
Sourcepub fn clear_scope(&mut self, scope: &ScopeKey)
pub fn clear_scope(&mut self, scope: &ScopeKey)
Remove all entities in a specific scope.