MeshTopology

Struct MeshTopology 

Source
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: HierarchyLevel

Our hierarchy level

§max_children: u8

Maximum children we can accept

§max_connections: u8

Maximum total connections

Implementations§

Source§

impl MeshTopology

Source

pub fn new( my_level: HierarchyLevel, max_children: u8, max_connections: u8, ) -> Self

Create a new mesh topology

Source

pub fn connection_count(&self) -> usize

Get total number of connections

Source

pub fn can_accept_connection(&self) -> bool

Check if we can accept more connections

Source

pub fn can_accept_child(&self) -> bool

Check if we can accept more children

Source

pub fn has_parent(&self) -> bool

Check if we have a parent

Source

pub fn set_parent(&mut self, node_id: NodeId) -> bool

Add a parent

Source

pub fn clear_parent(&mut self) -> Option<NodeId>

Remove parent

Source

pub fn add_child(&mut self, node_id: NodeId) -> bool

Add a child

Source

pub fn remove_child(&mut self, node_id: &NodeId) -> bool

Remove a child

Source

pub fn add_peer(&mut self, node_id: NodeId) -> bool

Add a peer

Source

pub fn remove_peer(&mut self, node_id: &NodeId) -> bool

Remove a peer

Source

pub fn all_connected(&self) -> Vec<NodeId>

Get all connected node IDs

Source

pub fn is_connected(&self, node_id: &NodeId) -> bool

Check if a node is connected in any role

Source

pub fn get_role(&self, node_id: &NodeId) -> Option<PeerRole>

Get the role of a connected node

Trait Implementations§

Source§

impl Clone for MeshTopology

Source§

fn clone(&self) -> MeshTopology

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MeshTopology

Source§

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

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

impl Default for MeshTopology

Source§

fn default() -> MeshTopology

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.