Host

Struct Host 

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

  1. construct a Host from a shared MacHandle
  2. register one or more LocalNodes with add_node
  3. attach callbacks to nodes / peers / wrappers
  4. drive progress with run or pump_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>

Source

pub fn new( mac: MacHandle<'a, P, IDENTITIES, PEERS, CHANNELS, ACKS, TX, FRAME, DUP>, ) -> Self

Create a host around a shared MAC handle.

Source

pub fn mac( &self, ) -> MacHandle<'a, P, IDENTITIES, PEERS, CHANNELS, ACKS, TX, FRAME, DUP>

Return the underlying shared MAC handle.

Source

pub fn pfs_control_options(&self) -> &SendOptions

Borrow the send options used for node-managed PFS control messages.

Source

pub fn set_pfs_control_options(&mut self, options: SendOptions)

Replace the send options used for node-managed PFS control messages.

Source

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.

Source

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.

Source

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.

Source

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.

Auto Trait Implementations§

§

impl<'a, P, const IDENTITIES: usize, const PEERS: usize, const CHANNELS: usize, const ACKS: usize, const TX: usize, const FRAME: usize, const DUP: usize> Freeze for Host<'a, P, IDENTITIES, PEERS, CHANNELS, ACKS, TX, FRAME, DUP>

§

impl<'a, P, const IDENTITIES: usize, const PEERS: usize, const CHANNELS: usize, const ACKS: usize, const TX: usize, const FRAME: usize, const DUP: usize> !RefUnwindSafe for Host<'a, P, IDENTITIES, PEERS, CHANNELS, ACKS, TX, FRAME, DUP>

§

impl<'a, P, const IDENTITIES: usize, const PEERS: usize, const CHANNELS: usize, const ACKS: usize, const TX: usize, const FRAME: usize, const DUP: usize> !Send for Host<'a, P, IDENTITIES, PEERS, CHANNELS, ACKS, TX, FRAME, DUP>

§

impl<'a, P, const IDENTITIES: usize, const PEERS: usize, const CHANNELS: usize, const ACKS: usize, const TX: usize, const FRAME: usize, const DUP: usize> !Sync for Host<'a, P, IDENTITIES, PEERS, CHANNELS, ACKS, TX, FRAME, DUP>

§

impl<'a, P, const IDENTITIES: usize, const PEERS: usize, const CHANNELS: usize, const ACKS: usize, const TX: usize, const FRAME: usize, const DUP: usize> Unpin for Host<'a, P, IDENTITIES, PEERS, CHANNELS, ACKS, TX, FRAME, DUP>

§

impl<'a, P, const IDENTITIES: usize, const PEERS: usize, const CHANNELS: usize, const ACKS: usize, const TX: usize, const FRAME: usize, const DUP: usize> !UnwindSafe for Host<'a, P, IDENTITIES, PEERS, CHANNELS, ACKS, TX, FRAME, DUP>

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

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
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.