Struct chord_rs_core::Node
source · pub struct Node { /* private fields */ }Expand description
A reference to a node in the chord ring
Implementations§
source§impl Node
impl Node
pub fn new(addr: SocketAddr) -> Self
pub fn addr(&self) -> SocketAddr
pub fn with_id(id: impl Into<NodeId>, addr: SocketAddr) -> Self
pub fn id(&self) -> NodeId
sourcepub fn is_between_on_ring(id: u64, node1: u64, node2: u64) -> bool
pub fn is_between_on_ring(id: u64, node1: u64, node2: u64) -> bool
Returns true if the given id is between 2 nodes on a ring
Arguments
id- The id to checknode1- First node idnode2- Second node id
Examples
Check if 10 is between 5 and 15
use chord_rs_core::Node;
let id = 10;
let node1 = 5;
let node2 = 15;
assert_eq!(Node::is_between_on_ring(id, node1, node2), true);Check if 20 is between 15 and 5
use chord_rs_core::Node;
let id = 20;
let node1 = 15;
let node2 = 5;
assert_eq!(Node::is_between_on_ring(id, node1, node2), true);pub fn is_between_on_ring_exclusive(id: u64, node1: u64, node2: u64) -> bool
Trait Implementations§
source§impl PartialEq<Node> for Node
impl PartialEq<Node> for Node
impl StructuralPartialEq for Node
Auto Trait Implementations§
impl RefUnwindSafe for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl UnwindSafe for Node
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