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
group_id: String
node_message_type: NodeMessageType
edge_node_id: String
A message for edge-nodes
DeviceMessage
Fields
namespace: TopicNamespace
group_id: String
device_message_type: DeviceMessageType
edge_node_id: String
device_id: String
A message for devices
StateMessage
Fields
scada_host_id: String
A state message for scada systems
Implementations
sourceimpl TopicName
impl TopicName
sourcepub fn new_node_message(
namespace: TopicNamespace,
group_id: String,
node_message_type: NodeMessageType,
edge_node_id: String
) -> Self
pub 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 fn new_device_message(
namespace: TopicNamespace,
group_id: String,
device_message_type: DeviceMessageType,
edge_node_id: String,
device_id: String
) -> Self
pub 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 fn new_state_message(scada_host_id: String) -> Self
pub fn new_state_message(scada_host_id: String) -> Self
Constructs a new TopicName of type TopicName::StateMessage
Trait Implementations
sourceimpl PartialOrd<TopicName> for TopicName
impl PartialOrd<TopicName> for TopicName
sourcefn partial_cmp(&self, other: &TopicName) -> Option<Ordering>
fn partial_cmp(&self, other: &TopicName) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
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