pub struct IndexedDbStorage { /* private fields */ }Expand description
IndexedDB storage implementation with real browser storage
Implementations§
Source§impl IndexedDbStorage
impl IndexedDbStorage
Sourcepub fn new(db_name: String, store_name: String) -> Self
pub fn new(db_name: String, store_name: String) -> Self
Create a new IndexedDB storage instance
Sourcepub async fn initialize(&mut self) -> Result<(), StorageError>
pub async fn initialize(&mut self) -> Result<(), StorageError>
Initialize the IndexedDB database
Sourcepub fn is_indexeddb_available(&self) -> bool
pub fn is_indexeddb_available(&self) -> bool
Check if IndexedDB is available and working
Sourcepub async fn get_stats(&self) -> Result<StorageStats, StorageError>
pub async fn get_stats(&self) -> Result<StorageStats, StorageError>
Get storage statistics
Sourcepub async fn store_delta(
&mut self,
collection_id: &str,
delta: &[u8],
replica_id: &str,
operation_type: &str,
) -> Result<(), StorageError>
pub async fn store_delta( &mut self, collection_id: &str, delta: &[u8], replica_id: &str, operation_type: &str, ) -> Result<(), StorageError>
Store a CRDT delta
Sourcepub async fn get_deltas(
&mut self,
collection_id: &str,
from_timestamp: Option<u64>,
to_timestamp: Option<u64>,
) -> Result<Vec<DeltaRecord>, StorageError>
pub async fn get_deltas( &mut self, collection_id: &str, from_timestamp: Option<u64>, to_timestamp: Option<u64>, ) -> Result<Vec<DeltaRecord>, StorageError>
Get CRDT deltas for a collection
Sourcepub async fn store_metadata(
&mut self,
metadata: &CollectionMetadata,
) -> Result<(), StorageError>
pub async fn store_metadata( &mut self, metadata: &CollectionMetadata, ) -> Result<(), StorageError>
Store collection metadata
Sourcepub async fn get_metadata(
&mut self,
collection_id: &str,
) -> Result<Option<CollectionMetadata>, StorageError>
pub async fn get_metadata( &mut self, collection_id: &str, ) -> Result<Option<CollectionMetadata>, StorageError>
Get collection metadata
Sourcepub async fn list_collections(
&mut self,
) -> Result<Vec<CollectionMetadata>, StorageError>
pub async fn list_collections( &mut self, ) -> Result<Vec<CollectionMetadata>, StorageError>
List all collections
Sourcepub async fn store_peer(&mut self, peer: &PeerInfo) -> Result<(), StorageError>
pub async fn store_peer(&mut self, peer: &PeerInfo) -> Result<(), StorageError>
Store peer information
Sourcepub async fn get_peer(
&mut self,
peer_id: &str,
) -> Result<Option<PeerInfo>, StorageError>
pub async fn get_peer( &mut self, peer_id: &str, ) -> Result<Option<PeerInfo>, StorageError>
Get peer information
Sourcepub async fn list_peers(&mut self) -> Result<Vec<PeerInfo>, StorageError>
pub async fn list_peers(&mut self) -> Result<Vec<PeerInfo>, StorageError>
List all peers
Sourcepub async fn cleanup_old_deltas(
&mut self,
collection_id: &str,
keep_count: usize,
) -> Result<(), StorageError>
pub async fn cleanup_old_deltas( &mut self, collection_id: &str, keep_count: usize, ) -> Result<(), StorageError>
Clean up old deltas
Sourcepub async fn clear_all(&mut self) -> Result<(), StorageError>
pub async fn clear_all(&mut self) -> Result<(), StorageError>
Clear all data
Trait Implementations§
Source§impl Clone for IndexedDbStorage
impl Clone for IndexedDbStorage
Source§impl LocalStorage for IndexedDbStorage
impl LocalStorage for IndexedDbStorage
Source§fn set<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 self,
key: &'life1 str,
value: &'life2 T,
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
fn set<'life0, 'life1, 'life2, 'async_trait, T>( &'life0 self, key: &'life1 str, value: &'life2 T, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
Store a value with the given key
Source§fn get<'life0, 'life1, 'async_trait, T>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<T>, StorageError>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned + Send + Sync,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait, T>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<T>, StorageError>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned + Send + Sync,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieve a value by key
Source§fn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Remove a value by key
Source§fn keys<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn keys<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get all keys
Source§fn contains_key<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn contains_key<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Check if a key exists
Source§fn len<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<usize, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn len<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<usize, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get the number of stored items
Auto Trait Implementations§
impl Freeze for IndexedDbStorage
impl !RefUnwindSafe for IndexedDbStorage
impl Send for IndexedDbStorage
impl Sync for IndexedDbStorage
impl Unpin for IndexedDbStorage
impl !UnwindSafe for IndexedDbStorage
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