pub struct HostApplication<T> { /* private fields */ }Expand description
The Host Application engine.
Implementations§
Source§impl<T: MqttTransport> HostApplication<T>
impl<T: MqttTransport> HostApplication<T>
Sourcepub fn new(config: HostConfig, transport: T) -> Self
pub fn new(config: HostConfig, transport: T) -> Self
Create the engine. Call HostApplication::start to connect + birth.
Sourcepub async fn start(&mut self) -> Result<()>
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.
Sourcepub async fn publish_node_command(
&mut self,
group: &str,
edge: &str,
metrics: Vec<Metric>,
) -> Result<()>
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.
Sourcepub async fn publish_device_command(
&mut self,
group: &str,
edge: &str,
device: &str,
metrics: Vec<Metric>,
) -> Result<()>
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.
Sourcepub async fn recv_and_handle(&mut self) -> Result<Option<HostEvent>>
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.
Sourcepub async fn handle_incoming(
&mut self,
message: &IncomingMessage,
) -> Result<HostEvent>
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.