[][src]Struct sharded::Shard

pub struct Shard<T> { /* fields omitted */ }

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]

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]

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]

Auto Trait Implementations

impl<T> RefUnwindSafe for Shard<T> where
    T: RefUnwindSafe

impl<T> Send for Shard<T> where
    T: Send

impl<T> Sync for Shard<T> where
    T: Sync

impl<T> Unpin for Shard<T> where
    T: Unpin

impl<T> UnwindSafe for Shard<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.