Skip to main content

MeshNodeFSM

Struct MeshNodeFSM 

Source
pub struct MeshNodeFSM { /* private fields */ }
Expand description

Top-level state machine for a mesh node.

Owns the local Identity, every per-peer HandshakeFSM, and the coarse FSMState. MeshNodeFSM::process is the single entry point: feed it an Input, get back a Vec<Output>. No I/O happens here — outputs are commands the driver must execute.

Implementations§

Source§

impl MeshNodeFSM

Source

pub fn new() -> Self

Source

pub fn with_identity(identity: Identity) -> Self

Source

pub fn state(&self) -> FSMState

Source

pub fn id(&self) -> &PeerID

Source

pub fn is_connected(&self, peer: &PeerID) -> bool

Source

pub fn channel_open_for_msg<Msg: UserMsgPayload>( &self, peer: &PeerID, msg: &MsgPayload<Msg>, ) -> bool

Returns true if peer is allowed to deliver msg to us right now.

Source

pub fn connected_peers(&self) -> HashSet<PeerID>

Source

pub fn connected_number(&self) -> usize

Source

pub fn handle_init_handshake<Msg: UserMsgPayload>( &mut self, with: PeerID, mode: HandshakeMode, strategy: HandshakeStrategy, ) -> Result<Vec<Output<Msg>>>

Source

pub fn handle_init_open_offer<Msg: UserMsgPayload>( &mut self, ) -> Result<Vec<Output<Msg>>>

Source

pub fn handle_open_offer_created<Msg: UserMsgPayload>( &mut self, sdp: String, ) -> Result<Vec<Output<Msg>>>

Source

pub fn handle_send<Msg: UserMsgPayload>( &mut self, peer_to: PeerID, data: MsgPayload<Msg>, ) -> Result<Vec<Output<Msg>>>

Source

pub fn handle_broadcast<Msg: UserMsgPayload>( &mut self, data: MsgPayload<Msg>, ) -> Result<Vec<Output<Msg>>>

Source

pub fn process<Msg: UserMsgPayload>( &mut self, input: Input<Msg>, ) -> Result<Vec<Output<Msg>>>

Source

pub fn identity(&self) -> &Identity

Source

pub fn connections_snapshot( &self, ) -> Vec<(PeerID, HandshakeState, HandshakeMode)>

Debug: snapshot of every connection’s (peer, state, mode).

Source

pub fn pending_handshakes_len(&self) -> usize

Debug: number of contexts in pending_handshakes.

Trait Implementations§

Source§

impl Default for MeshNodeFSM

Source§

fn default() -> Self

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> 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, 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.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V