pub struct Bucket { /* private fields */ }Implementations§
Source§impl Bucket
impl Bucket
pub fn new(max_nodes: usize, start_id: Id, end_id: Id) -> Self
Sourcepub fn add_node(&mut self, node: &Node) -> Result<(), BucketError>
pub fn add_node(&mut self, node: &Node) -> Result<(), BucketError>
Add a new ndoe, can fail if the bucket is full, if the node should not be inside this bucket and if the node is Local but there already is a local node in this bucket.
Sourcepub fn local(&self) -> Result<Node, BucketError>
pub fn local(&self) -> Result<Node, BucketError>
Check if the bucket contains the node that represents us
Sourcepub fn divide(&mut self) -> Option<Self>
pub fn divide(&mut self) -> Option<Self>
Divide bucket and split the ID space between the two. It also moves the nodes to the new bucket if necessary.
Sourcepub fn get(&self, i: usize) -> Result<Node, BucketError>
pub fn get(&self, i: usize) -> Result<Node, BucketError>
Get a node from the bucket by its index, can fail if index is incorrect.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Bucket
impl<'de> Deserialize<'de> for Bucket
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Bucket
impl RefUnwindSafe for Bucket
impl Send for Bucket
impl Sync for Bucket
impl Unpin for Bucket
impl UnsafeUnpin for Bucket
impl UnwindSafe for Bucket
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more