[][src]Struct hashring::HashRing

pub struct HashRing<T, S = DefaultHashBuilder> { /* fields omitted */ }

Methods

impl<T> HashRing<T>[src]

Hash Ring

A hash ring that provides consistent hashing for nodes that are added to it.

pub fn new() -> HashRing<T>[src]

Create a new HashRing.

impl<T, S> HashRing<T, S>[src]

pub fn with_hasher(hash_builder: S) -> HashRing<T, S>[src]

Creates an empty HashRing which will use the given hash builder.

pub fn len(&self) -> usize[src]

Get the number of nodes in the hash ring.

pub fn is_empty(&self) -> bool[src]

Returns true if the ring has no elements.

impl<T: Hash, S: BuildHasher> HashRing<T, S>[src]

pub fn add(&mut self, node: T)[src]

Add node to the hash ring.

pub fn remove(&mut self, node: &T) -> Option<T>[src]

Remove node from the hash ring. Returns an Option that will contain the node if it was in the hash ring or None if it was not present.

pub fn get<U: Hash>(&mut self, key: &U) -> Option<&T>[src]

Get the node responsible for key. Returns an Option that will contain the node if the hash ring is not empty or None if it was empty.

Trait Implementations

impl<T> Default for HashRing<T>[src]

Auto Trait Implementations

impl<T, S> RefUnwindSafe for HashRing<T, S> where
    S: RefUnwindSafe,
    T: RefUnwindSafe

impl<T, S> Send for HashRing<T, S> where
    S: Send,
    T: Send

impl<T, S> Sync for HashRing<T, S> where
    S: Sync,
    T: Sync

impl<T, S> Unpin for HashRing<T, S> where
    S: Unpin,
    T: Unpin

impl<T, S> UnwindSafe for HashRing<T, S> where
    S: UnwindSafe,
    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.