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:
- TopicName::NodeMessage for Edge Nodes
- TopicName::DeviceMessage for devices
- TopicName::StateMessage for SCADA applications
§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
A message for edge-nodes
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.
DeviceMessage
A message for devices
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.
StateMessage
A state message for scada systems
Implementations§
Source§impl TopicName
impl TopicName
Sourcepub const fn new_node_message(
namespace: TopicNamespace,
group_id: String,
node_message_type: NodeMessageType,
edge_node_id: String,
) -> Self
pub const fn new_node_message( namespace: TopicNamespace, group_id: String, node_message_type: NodeMessageType, edge_node_id: String, ) -> Self
Constructs a new TopicName of type TopicName::NodeMessage
Sourcepub const fn new_device_message(
namespace: TopicNamespace,
group_id: String,
device_message_type: DeviceMessageType,
edge_node_id: String,
device_id: String,
) -> Self
pub const fn new_device_message( namespace: TopicNamespace, group_id: String, device_message_type: DeviceMessageType, edge_node_id: String, device_id: String, ) -> Self
Constructs a new TopicName of type TopicName::DeviceMessage
Sourcepub const fn new_state_message(scada_host_id: String) -> Self
pub const fn new_state_message(scada_host_id: String) -> Self
Constructs a new TopicName of type TopicName::StateMessage