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

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

§edge_node_id: String

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

§

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.

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

§

StateMessage

A state message for scada systems

Fields

§scada_host_id: String

The id of the SCADA application

Implementations§

Source§

impl TopicName

Source

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

Source

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

Source

pub const fn new_state_message(scada_host_id: String) -> Self

Constructs a new TopicName of type TopicName::StateMessage

Trait Implementations§

Source§

impl Clone for TopicName

Source§

fn clone(&self) -> TopicName

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TopicName

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FromStr for TopicName

Source§

type Err = Box<dyn Error + Send + Sync>

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

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

impl PartialEq for TopicName

Source§

fn eq(&self, other: &TopicName) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl ToString for TopicName

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl StructuralPartialEq for TopicName

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.