pub enum TopicName {
    NodeMessage {
        namespace: TopicNamespace,
        group_id: String,
        node_message_type: NodeMessageType,
        edge_node_id: String,
    },
    DeviceMessage {
        namespace: TopicNamespace,
        group_id: String,
        device_message_type: DeviceMessageType,
        edge_node_id: String,
        device_id: String,
    },
    StateMessage {
        scada_host_id: String,
    },
}
Expand description

Rust representation of a sparkplug™ MQTT topic-name.

The TopicName can be one of three possible types:

Examples

let node = TopicName::new_node_message(TopicNamespace::SPBV1_0,
                                       "my_group".to_string(),
                                       NodeMessageType::NBIRTH,
                                       "nodeId".to_string());
assert_eq!(node.to_string(), "spBv1.0/my_group/NBIRTH/nodeId");

let topic: TopicName = TopicName::from_str("spBv1.0/my_group/NBIRTH/nodeId").unwrap();
assert_eq!(topic, node);
let device = TopicName::new_device_message(TopicNamespace::SPBV1_0,
                                           "my_group".to_string(),
                                           DeviceMessageType::DBIRTH,
                                           "nodeId".to_string(),
                                           "deviceId".to_string());
assert_eq!(device.to_string(), "spBv1.0/my_group/DBIRTH/nodeId/deviceId");

let topic: TopicName = TopicName::from_str("spBv1.0/my_group/DBIRTH/nodeId/deviceId").unwrap();
assert_eq!(topic, device);
let state = TopicName::new_state_message("scada_host_id".to_string());
assert_eq!(state.to_string(), "STATE/scada_host_id");

let topic: TopicName = TopicName::from_str("STATE/scada_host_id").unwrap();
assert_eq!(state, topic);

Variants

NodeMessage

Fields

namespace: TopicNamespace

The namespace element of the Topic Namespace is the root element that will define both the structure of the remaining namespace elements as well as the encoding used for the associated payload data.

group_id: String

The group_id element of the Topic Namespace provides for a logical grouping of MQTT EoN nodes into the MQTT Server and back out to the consuming MQTT Clients.

node_message_type: NodeMessageType

The message_type element of the Topic Namespace provides an indication as to how to handle the MQTT payload of the message.

edge_node_id: String

The edge_node_id element of the Sparkplug (TM) Topic Namespace uniquely identifies the MQTT EoN node within the infrastructure.

A message for edge-nodes

DeviceMessage

Fields

namespace: TopicNamespace

The namespace element of the Topic Namespace is the root element that will define both the structure of the remaining namespace elements as well as the encoding used for the associated payload data.

group_id: String

The group_id element of the Topic Namespace provides for a logical grouping of MQTT EoN nodes into the MQTT Server and back out to the consuming MQTT Clients.

device_message_type: DeviceMessageType

The message_type element of the Topic Namespace provides an indication as to how to handle the MQTT payload of the message.

edge_node_id: String

The edge_node_id element of the Sparkplug (TM) Topic Namespace uniquely identifies the MQTT EoN node within the infrastructure.

device_id: String

The device_id element of the Sparkplug (TM) Topic Namespace identifies a device attached (physically or logically) to the MQTT EoN node.

A message for devices

StateMessage

Fields

scada_host_id: String

The id of the SCADA application

A state message for scada systems

Implementations

Constructs a new TopicName of type TopicName::NodeMessage

Constructs a new TopicName of type TopicName::DeviceMessage

Constructs a new TopicName of type TopicName::StateMessage

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Converts the given value to a String. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.