pub struct InMemoryBackend { /* private fields */ }Expand description
In-memory implementation of all four sync traits
Thread-safe via Arc internals. Cloning shares the same state.
Implementations§
Source§impl InMemoryBackend
impl InMemoryBackend
Sourcepub fn new_initialized() -> Self
pub fn new_initialized() -> Self
Create a new backend that’s immediately ready for use in tests
Sourcepub async fn document_count(&self) -> usize
pub async fn document_count(&self) -> usize
Get total document count across all collections
Sourcepub async fn collection_count(&self) -> usize
pub async fn collection_count(&self) -> usize
Get the number of collections
Sourcepub async fn clear_collection(&self, collection: &str)
pub async fn clear_collection(&self, collection: &str)
Clear all documents in a collection
Sourcepub async fn set_deletion_policy(
&self,
collection: &str,
policy: DeletionPolicy,
)
pub async fn set_deletion_policy( &self, collection: &str, policy: DeletionPolicy, )
Set deletion policy for a collection
Trait Implementations§
Source§impl Clone for InMemoryBackend
impl Clone for InMemoryBackend
Source§fn clone(&self) -> InMemoryBackend
fn clone(&self) -> InMemoryBackend
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl DataSyncBackend for InMemoryBackend
impl DataSyncBackend for InMemoryBackend
Source§fn initialize<'life0, 'async_trait>(
&'life0 self,
config: BackendConfig,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn initialize<'life0, 'async_trait>(
&'life0 self,
config: BackendConfig,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Initialize backend with configuration Read more
Source§fn shutdown<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn shutdown<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Shutdown gracefully Read more
Source§fn document_store(&self) -> Arc<dyn DocumentStore>
fn document_store(&self) -> Arc<dyn DocumentStore>
Get reference to document store implementation
Source§fn peer_discovery(&self) -> Arc<dyn PeerDiscovery>
fn peer_discovery(&self) -> Arc<dyn PeerDiscovery>
Get reference to peer discovery implementation
Source§fn sync_engine(&self) -> Arc<dyn SyncEngine>
fn sync_engine(&self) -> Arc<dyn SyncEngine>
Get reference to sync engine implementation
Source§fn is_ready<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn is_ready<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Check if backend is ready (initialized and not shut down)
Source§fn backend_info(&self) -> BackendInfo
fn backend_info(&self) -> BackendInfo
Get backend name/version for debugging
Source§impl Default for InMemoryBackend
impl Default for InMemoryBackend
Source§impl DocumentStore for InMemoryBackend
impl DocumentStore for InMemoryBackend
Source§fn upsert<'life0, 'life1, 'async_trait>(
&'life0 self,
collection: &'life1 str,
document: Document,
) -> Pin<Box<dyn Future<Output = Result<DocumentId>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn upsert<'life0, 'life1, 'async_trait>(
&'life0 self,
collection: &'life1 str,
document: Document,
) -> Pin<Box<dyn Future<Output = Result<DocumentId>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Store or update a document Read more
Source§fn query<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
collection: &'life1 str,
query: &'life2 Query,
) -> Pin<Box<dyn Future<Output = Result<Vec<Document>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn query<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
collection: &'life1 str,
query: &'life2 Query,
) -> Pin<Box<dyn Future<Output = Result<Vec<Document>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Retrieve documents matching a query Read more
Source§fn remove<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
collection: &'life1 str,
doc_id: &'life2 DocumentId,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn remove<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
collection: &'life1 str,
doc_id: &'life2 DocumentId,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Remove a document by ID Read more
Source§fn observe(&self, collection: &str, query: &Query) -> Result<ChangeStream>
fn observe(&self, collection: &str, query: &Query) -> Result<ChangeStream>
Register observer for live updates Read more
Source§fn delete<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
collection: &'life1 str,
doc_id: &'life2 DocumentId,
reason: Option<&'life3 str>,
) -> Pin<Box<dyn Future<Output = Result<DeleteResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn delete<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
collection: &'life1 str,
doc_id: &'life2 DocumentId,
reason: Option<&'life3 str>,
) -> Pin<Box<dyn Future<Output = Result<DeleteResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Delete a document according to collection policy (ADR-034) Read more
Source§fn deletion_policy(&self, collection: &str) -> DeletionPolicy
fn deletion_policy(&self, collection: &str) -> DeletionPolicy
Get the deletion policy for a collection Read more
Source§fn get_tombstones<'life0, 'life1, 'async_trait>(
&'life0 self,
collection: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Tombstone>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_tombstones<'life0, 'life1, 'async_trait>(
&'life0 self,
collection: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Tombstone>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get all tombstones for a collection Read more
Source§fn apply_tombstone<'life0, 'life1, 'async_trait>(
&'life0 self,
tombstone: &'life1 Tombstone,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn apply_tombstone<'life0, 'life1, 'async_trait>(
&'life0 self,
tombstone: &'life1 Tombstone,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Apply a tombstone received from sync Read more
Source§fn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
collection: &'life1 str,
doc_id: &'life2 DocumentId,
) -> Pin<Box<dyn Future<Output = Result<Option<Document>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
collection: &'life1 str,
doc_id: &'life2 DocumentId,
) -> Pin<Box<dyn Future<Output = Result<Option<Document>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Get a single document by ID Read more
Source§fn count<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
collection: &'life1 str,
query: &'life2 Query,
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn count<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
collection: &'life1 str,
query: &'life2 Query,
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Count documents matching a query Read more
Source§fn is_deleted<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
collection: &'life1 str,
doc_id: &'life2 DocumentId,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn is_deleted<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
collection: &'life1 str,
doc_id: &'life2 DocumentId,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Check if a document is deleted (tombstoned or soft-deleted) Read more
Source§impl PeerDiscovery for InMemoryBackend
impl PeerDiscovery for InMemoryBackend
Source§fn start<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn start<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Start discovery mechanism Read more
Source§fn stop<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stop<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Stop discovery Read more
Source§fn discovered_peers<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<PeerInfo>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn discovered_peers<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<PeerInfo>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get list of discovered peers Read more
Source§fn add_peer<'life0, 'life1, 'async_trait>(
&'life0 self,
address: &'life1 str,
transport: TransportType,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn add_peer<'life0, 'life1, 'async_trait>(
&'life0 self,
address: &'life1 str,
transport: TransportType,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Manually add a peer by address Read more
Source§fn wait_for_peer<'life0, 'life1, 'async_trait>(
&'life0 self,
peer_id: &'life1 PeerId,
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn wait_for_peer<'life0, 'life1, 'async_trait>(
&'life0 self,
peer_id: &'life1 PeerId,
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Wait for a specific peer to connect Read more
Source§fn on_peer_event(&self, callback: Box<dyn Fn(PeerEvent) + Send + Sync>)
fn on_peer_event(&self, callback: Box<dyn Fn(PeerEvent) + Send + Sync>)
Register callback for peer events Read more
Source§impl SyncEngine for InMemoryBackend
impl SyncEngine for InMemoryBackend
Source§fn start_sync<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn start_sync<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Start synchronization with discovered peers Read more
Source§fn stop_sync<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stop_sync<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Stop synchronization Read more
Source§fn subscribe<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
collection: &'life1 str,
_query: &'life2 Query,
) -> Pin<Box<dyn Future<Output = Result<SyncSubscription>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn subscribe<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
collection: &'life1 str,
_query: &'life2 Query,
) -> Pin<Box<dyn Future<Output = Result<SyncSubscription>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Create sync subscription for a collection Read more
Source§fn is_syncing<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn is_syncing<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Check if sync is currently active
Source§fn set_priority<'life0, 'life1, 'async_trait>(
&'life0 self,
collection: &'life1 str,
priority: Priority,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set_priority<'life0, 'life1, 'async_trait>(
&'life0 self,
collection: &'life1 str,
priority: Priority,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Set sync priority for a collection (optional) Read more
Source§fn force_sync<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn force_sync<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Force a sync round (push pending changes) Read more
Source§fn connect_to_peer<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
endpoint_id_hex: &'life1 str,
addresses: &'life2 [String],
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn connect_to_peer<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
endpoint_id_hex: &'life1 str,
addresses: &'life2 [String],
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Connect to a peer using their EndpointId and addresses (Issue #235) Read more
Auto Trait Implementations§
impl Freeze for InMemoryBackend
impl !RefUnwindSafe for InMemoryBackend
impl Send for InMemoryBackend
impl Sync for InMemoryBackend
impl Unpin for InMemoryBackend
impl UnsafeUnpin for InMemoryBackend
impl !UnwindSafe for InMemoryBackend
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