[−][src]Struct hashring::HashRing
Methods
impl<T> HashRing<T>
[src]
Hash Ring
A hash ring that provides consistent hashing for nodes that are added to it.
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
Auto Trait Implementations
impl<T, S> RefUnwindSafe for HashRing<T, S> where
S: RefUnwindSafe,
T: RefUnwindSafe,
S: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, S> Send for HashRing<T, S> where
S: Send,
T: Send,
S: Send,
T: Send,
impl<T, S> Sync for HashRing<T, S> where
S: Sync,
T: Sync,
S: Sync,
T: Sync,
impl<T, S> Unpin for HashRing<T, S> where
S: Unpin,
T: Unpin,
S: Unpin,
T: Unpin,
impl<T, S> UnwindSafe for HashRing<T, S> where
S: UnwindSafe,
T: UnwindSafe,
S: 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,
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.
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>,