pub struct ObjectCache { /* private fields */ }Expand description
Object cache — central identity-tracking container. Spec §B.2.
Implementations§
Source§impl ObjectCache
impl ObjectCache
Sourcepub fn register(&mut self, id: ObjectId, state: Vec<u8>) -> ObjectRef
pub fn register(&mut self, id: ObjectId, state: Vec<u8>) -> ObjectRef
Spec §B.6.3 register_object — inserts a new object into the
cache. If the ID already exists, the state is overwritten and
the version is incremented (MODIFIED).
Sourcepub fn weak_ref(&self, id: &ObjectId) -> Option<WeakObjectRef>
pub fn weak_ref(&self, id: &ObjectId) -> Option<WeakObjectRef>
Returns a weak reference if the object exists. Spec §B.6.4.
Sourcepub fn resolve(&self, weak: &WeakObjectRef) -> Option<&ObjectRef>
pub fn resolve(&self, weak: &WeakObjectRef) -> Option<&ObjectRef>
Resolves a weak reference. Returns None if the object was
removed or the version no longer matches
(Spec §B.7.4 optimistic-concurrency check).
Sourcepub fn mark_deleted(&mut self, id: &ObjectId) -> bool
pub fn mark_deleted(&mut self, id: &ObjectId) -> bool
Spec §B.6.5 mark_deleted — marks an object for deletion.
Actual removal happens on the next commit_all.
Sourcepub fn commit_all(&mut self) -> usize
pub fn commit_all(&mut self) -> usize
Spec §B.7.4 commit_all — marks all New/Modified objects
as Committed and removes Deleted objects.
Sourcepub fn rollback_all(&mut self) -> usize
pub fn rollback_all(&mut self) -> usize
Spec §B.7.4 rollback_all — removes New objects, restores
Modified/Deleted back to Committed (but not the state
bytes — the caller must hold a snapshot before register).