Skip to main content

HostApplication

Struct HostApplication 

Source
pub struct HostApplication<T> { /* private fields */ }
Expand description

The Host Application engine.

Implementations§

Source§

impl<T: MqttTransport> HostApplication<T>

Source

pub fn new(config: HostConfig, transport: T) -> Self

Create the engine. Call HostApplication::start to connect + birth.

Source

pub async fn start(&mut self) -> Result<()>

Connect (registering the offline STATE will), subscribe to the own STATE topic (QoS 1) and the data namespace (QoS 0), then publish the retained online STATE birth that shares the will’s timestamp.

§Errors

Propagates any transport error.

Source

pub async fn shutdown(&mut self) -> Result<()>

Publish a retained offline STATE and disconnect.

§Errors

Propagates any transport error.

Source

pub async fn publish_node_command( &mut self, group: &str, edge: &str, metrics: Vec<Metric>, ) -> Result<()>

Publish an NCMD to an Edge Node (QoS 0, retain=false).

§Errors

Propagates an invalid-id or transport error.

Source

pub async fn publish_device_command( &mut self, group: &str, edge: &str, device: &str, metrics: Vec<Metric>, ) -> Result<()>

Publish a DCMD to a Device (QoS 0, retain=false).

§Errors

Propagates an invalid-id or transport error.

Source

pub async fn recv_and_handle(&mut self) -> Result<Option<HostEvent>>

Receive the next inbound message and handle it; None if the stream closed.

§Errors

Propagates transport/decode errors.

Source

pub async fn handle_incoming( &mut self, message: &IncomingMessage, ) -> Result<HostEvent>

Handle one inbound message, advancing the per-Edge-Node state machine.

§Errors

Returns a decode/transport error; malformed topics/payloads are surfaced rather than panicking.

Auto Trait Implementations§

§

impl<T> Freeze for HostApplication<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for HostApplication<T>
where T: RefUnwindSafe,

§

impl<T> Send for HostApplication<T>
where T: Send,

§

impl<T> Sync for HostApplication<T>
where T: Sync,

§

impl<T> Unpin for HostApplication<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for HostApplication<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for HostApplication<T>
where T: UnwindSafe,

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