Skip to main content

InMemoryBackend

Struct InMemoryBackend 

Source
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

Source

pub fn new() -> Self

Create a new uninitialized backend

Source

pub fn new_initialized() -> Self

Create a new backend that’s immediately ready for use in tests

Source

pub async fn document_count(&self) -> usize

Get total document count across all collections

Source

pub async fn collection_count(&self) -> usize

Get the number of collections

Source

pub async fn clear_collection(&self, collection: &str)

Clear all documents in a collection

Source

pub async fn set_deletion_policy( &self, collection: &str, policy: DeletionPolicy, )

Set deletion policy for a collection

Trait Implementations§

Source§

impl Clone for InMemoryBackend

Source§

fn clone(&self) -> InMemoryBackend

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

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,

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,

Shutdown gracefully Read more
Source§

fn document_store(&self) -> Arc<dyn DocumentStore>

Get reference to document store implementation
Source§

fn peer_discovery(&self) -> Arc<dyn PeerDiscovery>

Get reference to peer discovery implementation
Source§

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,

Check if backend is ready (initialized and not shut down)
Source§

fn backend_info(&self) -> BackendInfo

Get backend name/version for debugging
Source§

fn as_any(&self) -> &dyn Any

Get backend as Any for downcasting to concrete types Read more
Source§

impl Default for InMemoryBackend

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

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,

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,

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,

Remove a document by ID Read more
Source§

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,

Delete a document according to collection policy (ADR-034) Read more
Source§

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,

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,

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,

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,

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,

Check if a document is deleted (tombstoned or soft-deleted) Read more
Source§

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,

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,

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,

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,

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,

Wait for a specific peer to connect Read more
Source§

fn on_peer_event(&self, callback: Box<dyn Fn(PeerEvent) + Send + Sync>)

Register callback for peer events Read more
Source§

fn get_peer_info<'life0, 'life1, 'async_trait>( &'life0 self, peer_id: &'life1 PeerId, ) -> Pin<Box<dyn Future<Output = Result<Option<PeerInfo>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get information about a specific peer
Source§

fn is_peer_connected<'life0, 'life1, 'async_trait>( &'life0 self, peer_id: &'life1 PeerId, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check if a specific peer is currently connected
Source§

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,

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,

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,

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,

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,

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,

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,

Connect to a peer using their EndpointId and addresses (Issue #235) Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more