pub struct WebRTCStore<S: Store> { /* private fields */ }Expand description
WebRTC store that fetches data from P2P network
Implementations§
Source§impl<S: Store + 'static> WebRTCStore<S>
impl<S: Store + 'static> WebRTCStore<S>
Sourcepub fn new(local_store: Arc<S>, config: WebRTCStoreConfig) -> Self
pub fn new(local_store: Arc<S>, config: WebRTCStoreConfig) -> Self
Create a new WebRTC store
Sourcepub fn forward_tx(&self) -> ForwardTx
pub fn forward_tx(&self) -> ForwardTx
Get the forward request sender (for passing to peers)
Sourcepub async fn start(&mut self, keys: Keys) -> Result<(), WebRTCStoreError>
pub async fn start(&mut self, keys: Keys) -> Result<(), WebRTCStoreError>
Start the WebRTC store (connect to relays, begin peer discovery)
Sourcepub async fn stats(&self) -> WebRTCStats
pub async fn stats(&self) -> WebRTCStats
Get statistics
Sourcepub async fn peer_count(&self) -> usize
pub async fn peer_count(&self) -> usize
Get connected peer count
Sourcepub async fn selector_summary(&self) -> SelectorSummary
pub async fn selector_summary(&self) -> SelectorSummary
Get peer selector summary statistics
Trait Implementations§
Source§impl<S: Store + 'static> Store for WebRTCStore<S>
impl<S: Store + 'static> Store for WebRTCStore<S>
Source§fn put<'life0, 'async_trait>(
&'life0 self,
hash: Hash,
data: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<bool, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn put<'life0, 'async_trait>(
&'life0 self,
hash: Hash,
data: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<bool, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Store data by its hash
Returns true if newly stored, false if already existed
Source§fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 Hash,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 Hash,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieve data by hash
Returns data or None if not found
Source§fn has<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 Hash,
) -> Pin<Box<dyn Future<Output = Result<bool, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn has<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 Hash,
) -> Pin<Box<dyn Future<Output = Result<bool, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Check if hash exists
Source§fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 Hash,
) -> Pin<Box<dyn Future<Output = Result<bool, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 Hash,
) -> Pin<Box<dyn Future<Output = Result<bool, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Delete by hash
Returns true if deleted, false if didn’t exist
Source§fn put_many<'life0, 'async_trait>(
&'life0 self,
items: Vec<([u8; 32], Vec<u8>)>,
) -> Pin<Box<dyn Future<Output = Result<usize, StoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn put_many<'life0, 'async_trait>(
&'life0 self,
items: Vec<([u8; 32], Vec<u8>)>,
) -> Pin<Box<dyn Future<Output = Result<usize, StoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Store multiple blobs.
Returns the number of newly stored items.
Source§fn set_max_bytes(&self, _max: u64)
fn set_max_bytes(&self, _max: u64)
Set maximum storage size in bytes. 0 = unlimited.
Source§fn stats<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StoreStats> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn stats<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StoreStats> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Get storage statistics
Source§fn evict_if_needed<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u64, StoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn evict_if_needed<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u64, StoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Evict unpinned items if over storage limit.
Returns number of bytes freed.
Source§fn pin<'life0, 'life1, 'async_trait>(
&'life0 self,
_hash: &'life1 [u8; 32],
) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn pin<'life0, 'life1, 'async_trait>(
&'life0 self,
_hash: &'life1 [u8; 32],
) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Pin a hash (increment ref count). Pinned items are not evicted.
Source§fn unpin<'life0, 'life1, 'async_trait>(
&'life0 self,
_hash: &'life1 [u8; 32],
) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn unpin<'life0, 'life1, 'async_trait>(
&'life0 self,
_hash: &'life1 [u8; 32],
) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Unpin a hash (decrement ref count). Item can be evicted when count reaches 0.
Auto Trait Implementations§
impl<S> Freeze for WebRTCStore<S>
impl<S> !RefUnwindSafe for WebRTCStore<S>
impl<S> Send for WebRTCStore<S>
impl<S> Sync for WebRTCStore<S>
impl<S> Unpin for WebRTCStore<S>
impl<S> UnsafeUnpin for WebRTCStore<S>
impl<S> !UnwindSafe for WebRTCStore<S>
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more