pub struct MemoryStorage { /* private fields */ }Expand description
In-memory CRDT storage for testing.
This implementation stores all data in memory using HashMap and Vec.
It’s thread-safe via RwLock but data is lost when dropped.
Auto-compaction is triggered when the number of updates for a document
exceeds [AUTO_COMPACT_THRESHOLD], keeping the most recent
[AUTO_COMPACT_KEEP] updates.
Implementations§
Source§impl MemoryStorage
impl MemoryStorage
Trait Implementations§
Source§impl CrdtStorage for MemoryStorage
impl CrdtStorage for MemoryStorage
Source§fn load_doc(&self, name: &str) -> StorageResult<Option<Vec<u8>>>
fn load_doc(&self, name: &str) -> StorageResult<Option<Vec<u8>>>
Load the full document state as a binary blob. Read more
Source§fn save_doc(&self, name: &str, state: &[u8]) -> StorageResult<()>
fn save_doc(&self, name: &str, state: &[u8]) -> StorageResult<()>
Save the full document state. Read more
Source§fn delete_doc(&self, name: &str) -> StorageResult<()>
fn delete_doc(&self, name: &str) -> StorageResult<()>
Delete a document and all its updates.
Source§fn append_update_with_device(
&self,
name: &str,
update: &[u8],
origin: UpdateOrigin,
device_id: Option<&str>,
device_name: Option<&str>,
) -> StorageResult<i64>
fn append_update_with_device( &self, name: &str, update: &[u8], origin: UpdateOrigin, device_id: Option<&str>, device_name: Option<&str>, ) -> StorageResult<i64>
Append an incremental update with device attribution. Read more
Source§fn get_updates_since(
&self,
name: &str,
since_id: i64,
) -> StorageResult<Vec<CrdtUpdate>>
fn get_updates_since( &self, name: &str, since_id: i64, ) -> StorageResult<Vec<CrdtUpdate>>
Get all updates for a document since a given update ID. Read more
Source§fn get_all_updates(&self, name: &str) -> StorageResult<Vec<CrdtUpdate>>
fn get_all_updates(&self, name: &str) -> StorageResult<Vec<CrdtUpdate>>
Get all updates for a document.
Source§fn get_state_at(
&self,
name: &str,
update_id: i64,
) -> StorageResult<Option<Vec<u8>>>
fn get_state_at( &self, name: &str, update_id: i64, ) -> StorageResult<Option<Vec<u8>>>
Get the state of a document at a specific point in history. Read more
Source§fn compact(&self, name: &str, keep_updates: usize) -> StorageResult<()>
fn compact(&self, name: &str, keep_updates: usize) -> StorageResult<()>
Compact old updates into the document snapshot. Read more
Source§fn get_latest_update_id(&self, name: &str) -> StorageResult<i64>
fn get_latest_update_id(&self, name: &str) -> StorageResult<i64>
Get the latest update ID for a document. Read more
Source§fn rename_doc(&self, old_name: &str, new_name: &str) -> StorageResult<()>
fn rename_doc(&self, old_name: &str, new_name: &str) -> StorageResult<()>
Rename a document by copying its state and updates to a new name. Read more
Source§fn clear_updates(&self, name: &str) -> StorageResult<()>
fn clear_updates(&self, name: &str) -> StorageResult<()>
Clear all updates for a document while keeping the snapshot. Read more
Source§fn append_update(
&self,
name: &str,
update: &[u8],
origin: UpdateOrigin,
) -> StorageResult<i64>
fn append_update( &self, name: &str, update: &[u8], origin: UpdateOrigin, ) -> StorageResult<i64>
Append an incremental update to the update log. Read more
Source§fn batch_append_updates(
&self,
updates: &[(&str, &[u8], UpdateOrigin)],
) -> StorageResult<Vec<i64>>
fn batch_append_updates( &self, updates: &[(&str, &[u8], UpdateOrigin)], ) -> StorageResult<Vec<i64>>
Append multiple updates atomically. Read more
Source§impl Debug for MemoryStorage
impl Debug for MemoryStorage
Source§impl Default for MemoryStorage
impl Default for MemoryStorage
Source§fn default() -> MemoryStorage
fn default() -> MemoryStorage
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MemoryStorage
impl RefUnwindSafe for MemoryStorage
impl Send for MemoryStorage
impl Sync for MemoryStorage
impl Unpin for MemoryStorage
impl UnsafeUnpin for MemoryStorage
impl UnwindSafe for MemoryStorage
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
Mutably borrows from an owned value. Read more