Client

Trait Client 

Source
pub trait Client {
    // Required methods
    fn disconnect<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), ()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn publish_state_message<'life0, 'async_trait>(
        &'life0 self,
        topic: StateTopic,
        payload: StatePayload,
    ) -> Pin<Box<dyn Future<Output = Result<(), ()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn try_publish_state_message<'life0, 'async_trait>(
        &'life0 self,
        topic: StateTopic,
        payload: StatePayload,
    ) -> Pin<Box<dyn Future<Output = Result<(), ()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn publish_node_message<'life0, 'async_trait>(
        &'life0 self,
        topic: NodeTopic,
        payload: Payload,
    ) -> Pin<Box<dyn Future<Output = Result<(), ()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn try_publish_node_message<'life0, 'async_trait>(
        &'life0 self,
        topic: NodeTopic,
        payload: Payload,
    ) -> Pin<Box<dyn Future<Output = Result<(), ()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn publish_device_message<'life0, 'async_trait>(
        &'life0 self,
        topic: DeviceTopic,
        payload: Payload,
    ) -> Pin<Box<dyn Future<Output = Result<(), ()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn try_publish_device_message<'life0, 'async_trait>(
        &'life0 self,
        topic: DeviceTopic,
        payload: Payload,
    ) -> Pin<Box<dyn Future<Output = Result<(), ()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn subscribe_many<'life0, 'async_trait>(
        &'life0 self,
        topics: Vec<TopicFilter>,
    ) -> Pin<Box<dyn Future<Output = Result<(), ()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn subscribe<'life0, 'async_trait>(
        &'life0 self,
        topic: TopicFilter,
    ) -> Pin<Box<dyn Future<Output = Result<(), ()>> + Send + 'async_trait>>
       where Self: Sync + 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

A trait for implementing a type that acts as a Sparkplug Client

Required Methods§

Source

fn disconnect<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), ()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Disconnects the client.

Source

fn publish_state_message<'life0, 'async_trait>( &'life0 self, topic: StateTopic, payload: StatePayload, ) -> Pin<Box<dyn Future<Output = Result<(), ()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Publishes a state message to the specified state topic.

This method will yield to the async runtime until the message is accepted by the client

Source

fn try_publish_state_message<'life0, 'async_trait>( &'life0 self, topic: StateTopic, payload: StatePayload, ) -> Pin<Box<dyn Future<Output = Result<(), ()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Attempts to publish a state message to the specified state topic.

Unlike publish_state_message, this method may return early if the client cannot process the message e.g the message queue is full.

Source

fn publish_node_message<'life0, 'async_trait>( &'life0 self, topic: NodeTopic, payload: Payload, ) -> Pin<Box<dyn Future<Output = Result<(), ()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Publishes a message to a node-specific topic.

This method will yield to the async runtime until the message is accepted by the client

Source

fn try_publish_node_message<'life0, 'async_trait>( &'life0 self, topic: NodeTopic, payload: Payload, ) -> Pin<Box<dyn Future<Output = Result<(), ()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Attempts to publish a message to a node-specific topic.

Unlike publish_node_message, this method may return early if the client cannot process the message e.g the message queue is full.

Source

fn publish_device_message<'life0, 'async_trait>( &'life0 self, topic: DeviceTopic, payload: Payload, ) -> Pin<Box<dyn Future<Output = Result<(), ()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Publishes a message to a device-specific topic.

This method will yield to the async runtime until the message is accepted by the client

Source

fn try_publish_device_message<'life0, 'async_trait>( &'life0 self, topic: DeviceTopic, payload: Payload, ) -> Pin<Box<dyn Future<Output = Result<(), ()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Attempts to publish a message to a device-specific topic.

Unlike publish_device_message, this method may return early if the client cannot process the message e.g the message queue is full.

Source

fn subscribe_many<'life0, 'async_trait>( &'life0 self, topics: Vec<TopicFilter>, ) -> Pin<Box<dyn Future<Output = Result<(), ()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Subscribes to multiple topics in a single operation.

Provided Methods§

Source

fn subscribe<'life0, 'async_trait>( &'life0 self, topic: TopicFilter, ) -> Pin<Box<dyn Future<Output = Result<(), ()>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait,

Subscribes to a single topic.

This is a convenience method that calls subscribe_many with a single topic.

Implementors§