pastry_dht/internal/pastry/
shared.rs

1#[derive(Debug, Clone, PartialEq)]
2pub struct KeyValuePair<T, U> {
3    pub key: T,
4    pub value: U,
5}
6
7impl<T, U> KeyValuePair<T, U> {
8    pub fn new(key: T, value: U) -> Self {
9        Self { key, value }
10    }
11
12    pub fn get_key(&self) -> &T {
13        &self.key
14    }
15
16    pub fn get_value(&self) -> &U {
17        &self.value
18    }
19}
20
21/// Pastry Network Config
22///
23#[derive(Debug, Clone)]
24pub struct Config {
25    pub k: usize,
26}
27
28impl Config {
29    /// Creates a new Pastry `Config` instance.
30    ///
31    /// # Arguments
32    ///
33    /// * `leaf_set_k` - The number of neighbors on each side that a node in
34    /// the Pastry network will have.
35    ///
36    /// # Returns
37    ///
38    /// A new Pastry `Config` object.
39    ///
40    pub fn new(leaf_set_k: usize) -> Self {
41        Config { k: leaf_set_k }
42    }
43}