pub struct Host<'a, P: Platform, const IDENTITIES: usize, const PEERS: usize, const CHANNELS: usize, const ACKS: usize, const TX: usize, const FRAME: usize, const DUP: usize> { /* private fields */ }Expand description
Multi-identity orchestration layer for the node API.
Host owns the shared MAC run loop and routes inbound events to the correct
LocalNode, including ephemeral PFS identities that belong to a long-term node.
Applications typically:
- construct a
Hostfrom a sharedMacHandle - register one or more
LocalNodes withadd_node - attach callbacks to nodes / peers / wrappers
- drive progress with
runorpump_once
run() is the preferred long-lived driver. pump_once() exists for callers that need to
multiplex UMSH progress with other async work using select!.
Implementations§
Source§impl<'a, P: Platform, const IDENTITIES: usize, const PEERS: usize, const CHANNELS: usize, const ACKS: usize, const TX: usize, const FRAME: usize, const DUP: usize> Host<'a, P, IDENTITIES, PEERS, CHANNELS, ACKS, TX, FRAME, DUP>
impl<'a, P: Platform, const IDENTITIES: usize, const PEERS: usize, const CHANNELS: usize, const ACKS: usize, const TX: usize, const FRAME: usize, const DUP: usize> Host<'a, P, IDENTITIES, PEERS, CHANNELS, ACKS, TX, FRAME, DUP>
Sourcepub fn new(
mac: MacHandle<'a, P, IDENTITIES, PEERS, CHANNELS, ACKS, TX, FRAME, DUP>,
) -> Self
pub fn new( mac: MacHandle<'a, P, IDENTITIES, PEERS, CHANNELS, ACKS, TX, FRAME, DUP>, ) -> Self
Create a host around a shared MAC handle.
Sourcepub fn mac(
&self,
) -> MacHandle<'a, P, IDENTITIES, PEERS, CHANNELS, ACKS, TX, FRAME, DUP>
pub fn mac( &self, ) -> MacHandle<'a, P, IDENTITIES, PEERS, CHANNELS, ACKS, TX, FRAME, DUP>
Return the underlying shared MAC handle.
Sourcepub fn pfs_control_options(&self) -> &SendOptions
pub fn pfs_control_options(&self) -> &SendOptions
Borrow the send options used for node-managed PFS control messages.
Sourcepub fn set_pfs_control_options(&mut self, options: SendOptions)
pub fn set_pfs_control_options(&mut self, options: SendOptions)
Replace the send options used for node-managed PFS control messages.
Sourcepub fn add_node(
&mut self,
identity_id: LocalIdentityId,
) -> LocalNode<MacHandle<'a, P, IDENTITIES, PEERS, CHANNELS, ACKS, TX, FRAME, DUP>>
pub fn add_node( &mut self, identity_id: LocalIdentityId, ) -> LocalNode<MacHandle<'a, P, IDENTITIES, PEERS, CHANNELS, ACKS, TX, FRAME, DUP>>
Create and register a LocalNode for an already-registered local identity.
The returned handle is cheap to clone and becomes the application-facing entry point for sending traffic and attaching callbacks for that identity.
Sourcepub fn node(
&self,
identity_id: LocalIdentityId,
) -> Option<LocalNode<MacHandle<'a, P, IDENTITIES, PEERS, CHANNELS, ACKS, TX, FRAME, DUP>>>
pub fn node( &self, identity_id: LocalIdentityId, ) -> Option<LocalNode<MacHandle<'a, P, IDENTITIES, PEERS, CHANNELS, ACKS, TX, FRAME, DUP>>>
Look up a previously added node by identity id.
Sourcepub async fn pump_once(
&mut self,
) -> Result<(), HostError<MacError<<P::Radio as Radio>::Error>>>
pub async fn pump_once( &mut self, ) -> Result<(), HostError<MacError<<P::Radio as Radio>::Error>>>
Drive the shared MAC until one wake cycle completes.
This is a single wake-driven step, not a non-blocking poll. It waits until the MAC has meaningful work to do (radio activity or a protocol deadline), dispatches any resulting callbacks, services PFS command handling, and then returns.
Use this when you need to multiplex UMSH progress with other async sources using
select!. If UMSH owns the task, prefer run.
Sourcepub async fn run(
&mut self,
) -> Result<(), HostError<MacError<<P::Radio as Radio>::Error>>>
pub async fn run( &mut self, ) -> Result<(), HostError<MacError<<P::Radio as Radio>::Error>>>
Run the shared MAC/Host loop forever.
This is the preferred long-lived driver for node-based applications. It keeps the runtime wake policy inside the MAC/Host stack rather than requiring callers to write poll/sleep loops themselves.