[−][src]Struct sharded::Shard
The sharded lock collection. This is the main data type in the crate. See also the type aliases
Map
, Set
, and so on.
Examples
Shard a std::collections::HashMap
using std::sync::RwLock
use std::collections::HashMap; use std::sync::RwLock; use sharded::{ShardLock, Shard}; let users = Shard::<RwLock<_>>::from(HashMap::<&str, User>::new()); let guard = users.read(&"uid-31356"); let user: Option<&User> = guard.get(&"uid-31356");
Implementations
impl<T> Shard<T>
[src]
pub fn insert<K, V>(&self, k: K, v: V) -> Option<V> where
K: Hash + Eq + Clone,
V: Clone,
T: Lock<HashMap<K, V>>,
[src]
K: Hash + Eq + Clone,
V: Clone,
T: Lock<HashMap<K, V>>,
impl<T> Shard<T>
[src]
pub fn from<K, V, U>(inner: U) -> Self where
K: Hash,
V: ExtractShardKey<K>,
U: Collection<K, V>,
T: Lock<U>,
[src]
K: Hash,
V: ExtractShardKey<K>,
U: Collection<K, V>,
T: Lock<U>,
Create a new shard from an existing collection
impl<K: Hash + Eq + Clone, V: Clone> Shard<RwLock<HashMap<K, V, S>>>
[src]
pub fn new() -> Self
[src]
pub fn with_capacity(capacity: usize) -> Self
[src]
Trait Implementations
impl<K: Hash, V, U, L> ShardLock<K, V, U, L> for Shard<L> where
V: ExtractShardKey<K>,
U: Collection<K, V>,
L: Lock<U>,
[src]
V: ExtractShardKey<K>,
U: Collection<K, V>,
L: Lock<U>,
Auto Trait Implementations
impl<T> RefUnwindSafe for Shard<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Shard<T> where
T: Send,
T: Send,
impl<T> Sync for Shard<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Shard<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Shard<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,