pub struct InMemoryDhtStorage { /* private fields */ }Expand description
In-memory DHT storage with LRU eviction.
When the number of items exceeds max_items, the least recently
accessed item is evicted on the next put.
Implementations§
Trait Implementations§
Source§impl Default for InMemoryDhtStorage
impl Default for InMemoryDhtStorage
Source§impl DhtStorage for InMemoryDhtStorage
impl DhtStorage for InMemoryDhtStorage
Source§fn expire(&mut self, lifetime: Duration)
fn expire(&mut self, lifetime: Duration)
M175 BUG FIX: previously used Instant::now() - lifetime, which panics
when lifetime exceeds process uptime. Compare elapsed time forward
via Instant::duration_since instead.
Source§fn get_immutable(&mut self, target: &Id20) -> Option<ImmutableItem>
fn get_immutable(&mut self, target: &Id20) -> Option<ImmutableItem>
Retrieve an immutable item by its SHA-1 target hash. Read more
Source§fn put_immutable(&mut self, item: ImmutableItem) -> bool
fn put_immutable(&mut self, item: ImmutableItem) -> bool
Store an immutable item. Returns
true if newly inserted, false if updated.Source§fn get_mutable(
&mut self,
public_key: &[u8; 32],
salt: &[u8],
) -> Option<MutableItem>
fn get_mutable( &mut self, public_key: &[u8; 32], salt: &[u8], ) -> Option<MutableItem>
Retrieve a mutable item by public key and salt. Read more
Source§fn get_mutable_by_target(&mut self, target: &Id20) -> Option<MutableItem>
fn get_mutable_by_target(&mut self, target: &Id20) -> Option<MutableItem>
Retrieve a mutable item by its SHA-1 target (i.e.
SHA-1(public_key + salt)). Read moreSource§fn put_mutable(&mut self, item: MutableItem) -> bool
fn put_mutable(&mut self, item: MutableItem) -> bool
Auto Trait Implementations§
impl Freeze for InMemoryDhtStorage
impl RefUnwindSafe for InMemoryDhtStorage
impl Send for InMemoryDhtStorage
impl Sync for InMemoryDhtStorage
impl Unpin for InMemoryDhtStorage
impl UnsafeUnpin for InMemoryDhtStorage
impl UnwindSafe for InMemoryDhtStorage
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