pub struct RcuHashMap<K, V, L = RcuHashMapLock, S = RapidBuildHasher>where
K: Eq + Hash + Clone + RcuDroppable + Sync,
V: Clone + RcuDroppable + Sync,
L: LockLevel,
S: BuildHasher + Send + Sync + 'static,{ /* private fields */ }Expand description
A concurrent hash map that uses RCU for read synchronization and a mutex with a statically typed LockDep level for write synchronization.
By default, this map uses rapidhash::RapidBuildHasher, which provides high performance.
However, if this map holds keys which may be attacker-controlled, consider using
std::collections::hash_map::RandomState instead.
Implementations§
Source§impl<K, V, L> RcuHashMap<K, V, L, RapidBuildHasher>
impl<K, V, L> RcuHashMap<K, V, L, RapidBuildHasher>
Source§impl<K, V, S> RcuHashMap<K, V, RcuHashMapLock, S>where
K: Eq + Hash + Clone + RcuDroppable + Sync,
V: Clone + RcuDroppable + Sync,
S: BuildHasher + Send + Sync + 'static,
impl<K, V, S> RcuHashMap<K, V, RcuHashMapLock, S>where
K: Eq + Hash + Clone + RcuDroppable + Sync,
V: Clone + RcuDroppable + Sync,
S: BuildHasher + Send + Sync + 'static,
Sourcepub fn with_capacity_and_hasher(capacity: usize, hash_builder: S) -> Self
pub fn with_capacity_and_hasher(capacity: usize, hash_builder: S) -> Self
Creates a new hash map with the given capacity and hasher.
Sourcepub fn with_hasher(hash_builder: S) -> Self
pub fn with_hasher(hash_builder: S) -> Self
Creates a new hash map with the given hasher.
Methods from Deref<Target = DynamicRcuHashMap<K, V, S>>§
Sourcepub fn get<'a, Q>(&self, scope: &'a RcuReadScope, key: &Q) -> Option<&'a V>
pub fn get<'a, Q>(&self, scope: &'a RcuReadScope, key: &Q) -> Option<&'a V>
Returns a reference to the value associated with the given key, if it exists.
The returned reference is bound to the lifetime of the RcuReadScope.
Sourcepub fn lock(&self) -> RcuHashMapGuard<'_, K, V, S>
pub fn lock(&self) -> RcuHashMapGuard<'_, K, V, S>
Locks the map for exclusive access, returning a guard that allows mutation.
Sourcepub fn insert(&self, key: K, value: V) -> Option<V>
pub fn insert(&self, key: K, value: V) -> Option<V>
Inserts a key-value pair into the map, returning the old value if the key was already present.
Sourcepub fn remove<Q>(&self, key: &Q) -> Option<V>
pub fn remove<Q>(&self, key: &Q) -> Option<V>
Removes a key from the map, returning the value if the key was present.
Sourcepub fn iter<'a>(
&'a self,
scope: &'a RcuReadScope,
) -> impl Iterator<Item = (&'a K, &'a V)>
pub fn iter<'a>( &'a self, scope: &'a RcuReadScope, ) -> impl Iterator<Item = (&'a K, &'a V)>
Returns an iterator over the map’s entries.
Sourcepub fn keys<'a>(
&'a self,
scope: &'a RcuReadScope,
) -> impl Iterator<Item = &'a K>
pub fn keys<'a>( &'a self, scope: &'a RcuReadScope, ) -> impl Iterator<Item = &'a K>
Returns an iterator over the map’s keys.
Sourcepub fn values<'a>(
&'a self,
scope: &'a RcuReadScope,
) -> impl Iterator<Item = &'a V>
pub fn values<'a>( &'a self, scope: &'a RcuReadScope, ) -> impl Iterator<Item = &'a V>
Returns an iterator over the map’s values.
Trait Implementations§
Source§impl<K, V, L, S> Debug for RcuHashMap<K, V, L, S>where
K: Eq + Hash + Debug + Clone + RcuDroppable + Sync,
V: Debug + Clone + RcuDroppable + Sync,
L: LockLevel,
S: BuildHasher + Send + Sync + 'static,
impl<K, V, L, S> Debug for RcuHashMap<K, V, L, S>where
K: Eq + Hash + Debug + Clone + RcuDroppable + Sync,
V: Debug + Clone + RcuDroppable + Sync,
L: LockLevel,
S: BuildHasher + Send + Sync + 'static,
Source§impl<K, V> Default for RcuHashMap<K, V, RcuHashMapLock, RapidBuildHasher>
impl<K, V> Default for RcuHashMap<K, V, RcuHashMapLock, RapidBuildHasher>
Source§impl<K, V, L, S> Deref for RcuHashMap<K, V, L, S>where
K: Eq + Hash + Clone + RcuDroppable + Sync,
V: Clone + RcuDroppable + Sync,
L: LockLevel,
S: BuildHasher + Send + Sync + 'static,
impl<K, V, L, S> Deref for RcuHashMap<K, V, L, S>where
K: Eq + Hash + Clone + RcuDroppable + Sync,
V: Clone + RcuDroppable + Sync,
L: LockLevel,
S: BuildHasher + Send + Sync + 'static,
Source§impl<K, V, L, S> MutexLike for RcuHashMap<K, V, L, S>where
K: Eq + Hash + Clone + RcuDroppable + Sync,
V: Clone + RcuDroppable + Sync,
L: LockLevel,
S: BuildHasher + Send + Sync + 'static,
impl<K, V, L, S> MutexLike for RcuHashMap<K, V, L, S>where
K: Eq + Hash + Clone + RcuDroppable + Sync,
V: Clone + RcuDroppable + Sync,
L: LockLevel,
S: BuildHasher + Send + Sync + 'static,
type Guard<'a> = RcuHashMapGuard<'a, K, V, S> where Self: 'a
type Context = <DynamicRcuHashMap<K, V, S> as MutexLike>::Context
fn context() -> Self::Context
Source§fn lock(&self, context: &mut Self::Context) -> Self::Guard<'_>
fn lock(&self, context: &mut Self::Context) -> Self::Guard<'_>
level is the index of the locked mutex in the lock ordering.fn key(&self) -> *const ()where
Self: Sized,
impl<K, V, L, S> RcuDroppable for RcuHashMap<K, V, L, S>where
K: Eq + Hash + Clone + RcuDroppable + Sync,
V: Clone + RcuDroppable + Sync,
L: LockLevel + RcuDroppable,
S: BuildHasher + Send + Sync + 'static + RcuDroppable,
DynamicRcuHashMap<K, V, S>: RcuDroppable,
PhantomData<L>: RcuDroppable,
Source§impl<K, V, L, S> ResetDependencies for RcuHashMap<K, V, L, S>where
K: Eq + Hash + Clone + RcuDroppable + Sync,
V: Clone + RcuDroppable + Sync,
L: LockLevel,
S: BuildHasher + Send + Sync + 'static,
impl<K, V, L, S> ResetDependencies for RcuHashMap<K, V, L, S>where
K: Eq + Hash + Clone + RcuDroppable + Sync,
V: Clone + RcuDroppable + Sync,
L: LockLevel,
S: BuildHasher + Send + Sync + 'static,
Source§unsafe fn reset_dependencies(&self)
unsafe fn reset_dependencies(&self)
Auto Trait Implementations§
impl<K, V, L = RcuHashMapLock, S = BuildHasherDefault<RapidHasher>> !Freeze for RcuHashMap<K, V, L, S>
impl<K, V, L = RcuHashMapLock, S = BuildHasherDefault<RapidHasher>> !RefUnwindSafe for RcuHashMap<K, V, L, S>
impl<K, V, L, S> Send for RcuHashMap<K, V, L, S>
impl<K, V, L, S> Sync for RcuHashMap<K, V, L, S>where
L: Sync,
impl<K, V, L, S> Unpin for RcuHashMap<K, V, L, S>
impl<K, V, L, S> UnsafeUnpin for RcuHashMap<K, V, L, S>where
S: UnsafeUnpin,
impl<K, V, L, S> UnwindSafe for RcuHashMap<K, V, L, S>
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
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
§impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
fn fidl_into_native(self) -> Box<N>
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> ⓘ
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> ⓘ
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