Enum sparkplug_rs::TopicName
source · [−]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
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
sourceimpl 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
Trait Implementations
impl StructuralPartialEq for TopicName
Auto Trait Implementations
impl RefUnwindSafe for TopicName
impl Send for TopicName
impl Sync for TopicName
impl Unpin for TopicName
impl UnwindSafe for TopicName
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more