Consistent

Struct Consistent 

Source
pub struct Consistent { /* private fields */ }

Implementations§

Source§

impl Consistent

Source

pub fn new() -> Self

Examples found in repository?
examples/demo.rs (line 4)
3fn main() {
4    let c = Consistent::new();
5    c.add("cacheA");
6    c.add("cacheB");
7    c.add("cacheC");
8    let users = vec![
9        "user_mcnulty",
10        "user_bunk",
11        "user_omar",
12        "user_bunny",
13        "user_stringer",
14    ];
15    println!("initial state [A, B, C]");
16    for u in users.iter() {
17        let server = c.get(u).unwrap();
18        println!("{} => {}", u, server);
19    }
20    c.add("cacheD");
21    c.add("cacheE");
22    println!("with cacheD, cacheE added [A, B, C, D, E]");
23    for u in users.iter() {
24        let server = c.get(u).unwrap();
25        println!("{} => {}", u, server);
26    }
27    c.remove("cacheC");
28    println!("with cacheC removed [A, B, D, E]");
29    for u in users.iter() {
30        let server = c.get(u).unwrap();
31        println!("{} => {}", u, server);
32    }
33}
Source

pub fn with_number_of_replicas(self, number_of_replicas: usize) -> Self

Source

pub fn add(&self, elt: impl Into<FastStr>)

Examples found in repository?
examples/demo.rs (line 5)
3fn main() {
4    let c = Consistent::new();
5    c.add("cacheA");
6    c.add("cacheB");
7    c.add("cacheC");
8    let users = vec![
9        "user_mcnulty",
10        "user_bunk",
11        "user_omar",
12        "user_bunny",
13        "user_stringer",
14    ];
15    println!("initial state [A, B, C]");
16    for u in users.iter() {
17        let server = c.get(u).unwrap();
18        println!("{} => {}", u, server);
19    }
20    c.add("cacheD");
21    c.add("cacheE");
22    println!("with cacheD, cacheE added [A, B, C, D, E]");
23    for u in users.iter() {
24        let server = c.get(u).unwrap();
25        println!("{} => {}", u, server);
26    }
27    c.remove("cacheC");
28    println!("with cacheC removed [A, B, D, E]");
29    for u in users.iter() {
30        let server = c.get(u).unwrap();
31        println!("{} => {}", u, server);
32    }
33}
Source

pub fn remove(&self, elt: impl AsRef<str>)

Examples found in repository?
examples/demo.rs (line 27)
3fn main() {
4    let c = Consistent::new();
5    c.add("cacheA");
6    c.add("cacheB");
7    c.add("cacheC");
8    let users = vec![
9        "user_mcnulty",
10        "user_bunk",
11        "user_omar",
12        "user_bunny",
13        "user_stringer",
14    ];
15    println!("initial state [A, B, C]");
16    for u in users.iter() {
17        let server = c.get(u).unwrap();
18        println!("{} => {}", u, server);
19    }
20    c.add("cacheD");
21    c.add("cacheE");
22    println!("with cacheD, cacheE added [A, B, C, D, E]");
23    for u in users.iter() {
24        let server = c.get(u).unwrap();
25        println!("{} => {}", u, server);
26    }
27    c.remove("cacheC");
28    println!("with cacheC removed [A, B, D, E]");
29    for u in users.iter() {
30        let server = c.get(u).unwrap();
31        println!("{} => {}", u, server);
32    }
33}
Source

pub fn set(&self, elts: Vec<impl Into<FastStr>>)

Source

pub fn members(&self) -> Vec<FastStr>

Source

pub fn get(&self, name: impl AsRef<str>) -> Result<FastStr, Error>

Examples found in repository?
examples/demo.rs (line 17)
3fn main() {
4    let c = Consistent::new();
5    c.add("cacheA");
6    c.add("cacheB");
7    c.add("cacheC");
8    let users = vec![
9        "user_mcnulty",
10        "user_bunk",
11        "user_omar",
12        "user_bunny",
13        "user_stringer",
14    ];
15    println!("initial state [A, B, C]");
16    for u in users.iter() {
17        let server = c.get(u).unwrap();
18        println!("{} => {}", u, server);
19    }
20    c.add("cacheD");
21    c.add("cacheE");
22    println!("with cacheD, cacheE added [A, B, C, D, E]");
23    for u in users.iter() {
24        let server = c.get(u).unwrap();
25        println!("{} => {}", u, server);
26    }
27    c.remove("cacheC");
28    println!("with cacheC removed [A, B, D, E]");
29    for u in users.iter() {
30        let server = c.get(u).unwrap();
31        println!("{} => {}", u, server);
32    }
33}
Source

pub fn get_two( &self, name: impl AsRef<str>, ) -> Result<(FastStr, FastStr), Error>

Source

pub fn get_n( &self, name: impl AsRef<str>, n: usize, ) -> Result<Vec<FastStr>, Error>

Trait Implementations§

Source§

impl Debug for Consistent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Consistent

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.