Struct confitul::Node

source ·
pub struct Node {
    pub key: CKey,
    /* private fields */
}
Expand description

Node is an element of a ring.

In a typical setup, a host has several nodes which act as “virtual” entry points. Each node is responsible for keys which are lower, or equal, to its key value, and points to its “next” node.

Fields§

§key: CKey

Implementations§

Examples found in repository?
src/cluster.rs (line 36)
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
    pub fn resize(&mut self, size: usize) {
        while self.nodes.len() > size {
            let to_remove = self.nodes.iter().next().unwrap().0.clone();
            self.nodes.remove(&to_remove);
        }
        while self.nodes.len() < size {
            let node = Node::new_rand();
            match self.nodes.insert(node.key, node) {
                // Really, there should be no dupes here, we're talking
                // about *hopefully* random generation of 256 bit keys.
                // Having dupes is unlikely, should it happen, let's call it.
                Some(_) => panic!("duplicate node key"),
                None => {}
            }
        }
    }

Trait Implementations§

Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.