pub struct AnchorSidecar {
pub version: u32,
pub entities: BTreeMap<String, Vec<Anchor>>,
}Expand description
The engine-owned anchors sidecar document persisted at
ANCHOR_SIDECAR_PATH on the mem branch: entity id → its anchors.
Written only through engine commits (the crate::backend::MemBackend
sidecar seam). Rename rewrites the key atomically in the same commit as
the entity move; delete drops the key in the same commit as the entity
delete.
Fields§
§version: u32Document schema version.
entities: BTreeMap<String, Vec<Anchor>>Entity id (mem--slug) → its anchors. An entity with no anchors
carries no key (an empty vec is pruned on write).
Implementations§
Source§impl AnchorSidecar
impl AnchorSidecar
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
pub fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
Parse sidecar bytes; an absent/empty payload yields an empty document so callers need not special-case a fresh mem.
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Serialise to canonical pretty JSON with a trailing newline — diff-friendly on the mem branch.
Sourcepub fn get(&self, entity_id: &str) -> &[Anchor]
pub fn get(&self, entity_id: &str) -> &[Anchor]
The anchors recorded for entity_id, or an empty slice.
Sourcepub fn set(&mut self, entity_id: &str, anchors: Vec<Anchor>)
pub fn set(&mut self, entity_id: &str, anchors: Vec<Anchor>)
Replace entity_id’s anchors. An empty list prunes the key so the
sidecar never accumulates empty rows.
Sourcepub fn merge(
&mut self,
entity_id: &str,
unsets: &[AnchorUnset],
incoming: Vec<Anchor>,
)
pub fn merge( &mut self, entity_id: &str, unsets: &[AnchorUnset], incoming: Vec<Anchor>, )
Merge incoming into entity_id’s anchor row after applying
unsets — the write-path set arithmetic.
Unset applies first: each selector removes its matching anchors
(a selector matching nothing is a no-op). Then each incoming anchor
replaces the surviving anchor with the same
(artifact, grain, class) triple in place, and appends
otherwise — untouched anchors keep their bytes and their position.
Writing anchors never removes an anchor the call did not name in
unsets; an empty incoming merges nothing. A row emptied by
unsets prunes its key so the sidecar never accumulates empty rows.
Sourcepub fn remove(&mut self, entity_id: &str)
pub fn remove(&mut self, entity_id: &str)
Drop entity_id’s anchors entirely (delete leg). Idempotent.
Trait Implementations§
Source§impl Clone for AnchorSidecar
impl Clone for AnchorSidecar
Source§fn clone(&self) -> AnchorSidecar
fn clone(&self) -> AnchorSidecar
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AnchorSidecar
impl Debug for AnchorSidecar
Source§impl Default for AnchorSidecar
impl Default for AnchorSidecar
Source§impl<'de> Deserialize<'de> for AnchorSidecar
impl<'de> Deserialize<'de> for AnchorSidecar
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for AnchorSidecar
Source§impl PartialEq for AnchorSidecar
impl PartialEq for AnchorSidecar
Source§impl Serialize for AnchorSidecar
impl Serialize for AnchorSidecar
impl StructuralPartialEq for AnchorSidecar
Auto Trait Implementations§
impl Freeze for AnchorSidecar
impl RefUnwindSafe for AnchorSidecar
impl Send for AnchorSidecar
impl Sync for AnchorSidecar
impl Unpin for AnchorSidecar
impl UnsafeUnpin for AnchorSidecar
impl UnwindSafe for AnchorSidecar
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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