pub struct MeshTopology {
pub parent: Option<NodeId>,
pub children: Vec<NodeId>,
pub peers: Vec<NodeId>,
pub my_level: HierarchyLevel,
pub max_children: u8,
pub max_connections: u8,
}Expand description
Current mesh topology state
Fields§
§parent: Option<NodeId>Our parent node (if we have one)
children: Vec<NodeId>Our children nodes
peers: Vec<NodeId>Peer nodes at our level
my_level: HierarchyLevelOur hierarchy level
max_children: u8Maximum children we can accept
max_connections: u8Maximum total connections
Implementations§
Source§impl MeshTopology
impl MeshTopology
Sourcepub fn new(
my_level: HierarchyLevel,
max_children: u8,
max_connections: u8,
) -> Self
pub fn new( my_level: HierarchyLevel, max_children: u8, max_connections: u8, ) -> Self
Create a new mesh topology
Sourcepub fn connection_count(&self) -> usize
pub fn connection_count(&self) -> usize
Get total number of connections
Sourcepub fn can_accept_connection(&self) -> bool
pub fn can_accept_connection(&self) -> bool
Check if we can accept more connections
Sourcepub fn can_accept_child(&self) -> bool
pub fn can_accept_child(&self) -> bool
Check if we can accept more children
Sourcepub fn has_parent(&self) -> bool
pub fn has_parent(&self) -> bool
Check if we have a parent
Sourcepub fn set_parent(&mut self, node_id: NodeId) -> bool
pub fn set_parent(&mut self, node_id: NodeId) -> bool
Add a parent
Sourcepub fn clear_parent(&mut self) -> Option<NodeId>
pub fn clear_parent(&mut self) -> Option<NodeId>
Remove parent
Sourcepub fn remove_child(&mut self, node_id: &NodeId) -> bool
pub fn remove_child(&mut self, node_id: &NodeId) -> bool
Remove a child
Sourcepub fn remove_peer(&mut self, node_id: &NodeId) -> bool
pub fn remove_peer(&mut self, node_id: &NodeId) -> bool
Remove a peer
Sourcepub fn all_connected(&self) -> Vec<NodeId>
pub fn all_connected(&self) -> Vec<NodeId>
Get all connected node IDs
Sourcepub fn is_connected(&self, node_id: &NodeId) -> bool
pub fn is_connected(&self, node_id: &NodeId) -> bool
Check if a node is connected in any role
Trait Implementations§
Source§impl Clone for MeshTopology
impl Clone for MeshTopology
Source§fn clone(&self) -> MeshTopology
fn clone(&self) -> MeshTopology
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MeshTopology
impl Debug for MeshTopology
Source§impl Default for MeshTopology
impl Default for MeshTopology
Source§fn default() -> MeshTopology
fn default() -> MeshTopology
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MeshTopology
impl RefUnwindSafe for MeshTopology
impl Send for MeshTopology
impl Sync for MeshTopology
impl Unpin for MeshTopology
impl UnwindSafe for MeshTopology
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