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
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

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 !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

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.