Struct xstack_kad::kbucket::KBucketTable
source · pub struct KBucketTable<Key, Value, const K: usize>where
Key: KBucketKey,{ /* private fields */ }Implementations§
source§impl<Key, Value, const K: usize> KBucketTable<Key, Value, K>where
Key: KBucketKey,
impl<Key, Value, const K: usize> KBucketTable<Key, Value, K>where
Key: KBucketKey,
sourcepub fn get(&self, key: &Key) -> Option<&Value>where
Key: PartialEq,
pub fn get(&self, key: &Key) -> Option<&Value>where
Key: PartialEq,
Returns value of given key.
sourcepub fn insert<Q>(&mut self, key: Q, value: Value) -> Option<(Key, Value)>
pub fn insert<Q>(&mut self, key: Q, value: Value) -> Option<(Key, Value)>
Push value into k-bucket’s bottom. and pop the LRU value from the k-bucket’s top if the k-bucket is full.
This function has no side effects if called with local_key.
sourcepub fn remove(&mut self, key: &Key) -> Option<Value>where
Key: PartialEq,
pub fn remove(&mut self, key: &Key) -> Option<Value>where
Key: PartialEq,
Remove the keypair from the table.
Returns None, if the key is not exists.
sourcepub fn closest_k(&self, target: &Key) -> KBucketTableIter<'_, Key, Value, K> ⓘ
pub fn closest_k(&self, target: &Key) -> KBucketTableIter<'_, Key, Value, K> ⓘ
Returns an iterator of up to k keys closest to target.
sourcepub fn iter(&self) -> KBucketTableIter<'_, Key, Value, K> ⓘ
pub fn iter(&self) -> KBucketTableIter<'_, Key, Value, K> ⓘ
Returns an iterator over all inserted keys.
sourcepub fn bucket_of_key(&self, key: &Key) -> Option<&KBucket<Key, Value>>
pub fn bucket_of_key(&self, key: &Key) -> Option<&KBucket<Key, Value>>
Get bucket of one key.
Auto Trait Implementations§
impl<Key, Value, const K: usize> Freeze for KBucketTable<Key, Value, K>
impl<Key, Value, const K: usize> RefUnwindSafe for KBucketTable<Key, Value, K>where
Key: RefUnwindSafe,
<<Key as KBucketKey>::Length as ArrayLength>::ArrayType<Option<usize>>: RefUnwindSafe,
Value: RefUnwindSafe,
impl<Key, Value, const K: usize> Send for KBucketTable<Key, Value, K>
impl<Key, Value, const K: usize> Sync for KBucketTable<Key, Value, K>
impl<Key, Value, const K: usize> Unpin for KBucketTable<Key, Value, K>where
Key: Unpin,
<<Key as KBucketKey>::Length as ArrayLength>::ArrayType<Option<usize>>: Unpin,
Value: Unpin,
impl<Key, Value, const K: usize> UnwindSafe for KBucketTable<Key, Value, K>where
Key: UnwindSafe,
<<Key as KBucketKey>::Length as ArrayLength>::ArrayType<Option<usize>>: UnwindSafe,
Value: UnwindSafe,
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