pub struct Store { /* private fields */ }Expand description
The graph store. Three maps: nodes, outgoing edges, incoming edges.
Clone backs the atomic-batch rollback: batch_update snapshots
the store before preparing items so a refused batch can restore the
pre-call graph wholesale.
Implementations§
Source§impl Store
impl Store
pub fn new() -> Store
Sourcepub fn upsert(&mut self, id: EntityId, entity: Entity)
pub fn upsert(&mut self, id: EntityId, entity: Entity)
Insert or update a node. If the node already exists, replace it.
Sourcepub fn remove(&mut self, id: &EntityId) -> Option<Entity>
pub fn remove(&mut self, id: &EntityId) -> Option<Entity>
Remove a node and cascade-delete all its edges.
pub fn get(&self, id: &EntityId) -> Option<&Entity>
pub fn get_mut(&mut self, id: &EntityId) -> Option<&mut Entity>
pub fn contains(&self, id: &EntityId) -> bool
pub fn all_ids(&self) -> impl Iterator<Item = &EntityId>
pub fn all_entities(&self) -> impl Iterator<Item = &Entity>
Sourcepub fn remove_entities_by_mem(&mut self, mem: &str) -> usize
pub fn remove_entities_by_mem(&mut self, mem: &str) -> usize
Drop every entity whose EntityId::mem() matches mem,
cascading edges via the existing Store::remove mechanism.
Returns the number of entities removed (excluding edge-only
cascades — same accounting as remove).
Used by [Engine::reload_one_mem] to clear one mem’s slice
of the store before reloading entities from the on-disk branch
tip. Pure-iteration implementation: walks all_ids(), filters
by mem, then calls remove on each. The 132-entity workspace
today reloads the whole store in <1 s so the per-mem filtered
case is microseconds; if the workspace ever grows past
10k entities the loop can switch to a mem-keyed bucket on
Store without changing this signature.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn add_edge(&mut self, from: EntityId, edge: Edge)
pub fn add_edge(&mut self, from: EntityId, edge: Edge)
Add an edge. Idempotent: if (from, to, type) exists, update source; else append. Stores in both out_edges and in_edges for bidirectional traversal.
Sourcepub fn remove_edge(&mut self, from: &EntityId, to: &EntityId, rel_type: &str)
pub fn remove_edge(&mut self, from: &EntityId, to: &EntityId, rel_type: &str)
Remove a specific edge by (from, to, type).
Sourcepub fn remove_edges_from(&mut self, id: &EntityId)
pub fn remove_edges_from(&mut self, id: &EntityId)
Remove all outgoing edges from a node (and their mirrors).
Sourcepub fn rename_node(&mut self, old_id: &EntityId, new_id: EntityId) -> bool
pub fn rename_node(&mut self, old_id: &EntityId, new_id: EntityId) -> bool
Rename a node. Updates all edge references.
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Total edge count (outgoing edges only, since in_edges are mirrors).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Store
impl RefUnwindSafe for Store
impl Send for Store
impl Sync for Store
impl Unpin for Store
impl UnsafeUnpin for Store
impl UnwindSafe for Store
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> Fruit for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more