Struct Topic
#[repr(transparent)]pub struct Topic(MqttStr);Expand description
A validated, borrowed MQTT topic name.
Topic names are used in PUBLISH packets to identify the subject of a
message. They must not contain wildcard characters (+, #), must not
be empty, and must satisfy the MqttStr constraints (≤ 65 535 bytes,
no U+0000).
This is an unsized type like str. Use &Topic for borrowed
references and TopicBuf for owned values.
Tuple Fields§
§0: MqttStrImplementations§
§impl Topic
impl Topic
pub const unsafe fn new_unchecked(s: &MqttStr) -> &Self
pub const unsafe fn new_unchecked(s: &MqttStr) -> &Self
pub const fn new(s: &MqttStr) -> Result<&Self, TopicError>
pub const fn new(s: &MqttStr) -> Result<&Self, TopicError>
Validate and create a new topic name from a validated MqttStr.
This only checks non-empty and no wildcard characters; MqttStr
guarantees length and null-character constraints.
§Errors
Returns TopicError if the string is empty or contains wildcard
characters (+, #).
pub const fn as_mqtt_str(&self) -> &MqttStr
pub const fn as_mqtt_str(&self) -> &MqttStr
View the topic as an MqttStr.
Trait Implementations§
§impl ToOwned for Topic
Available on crate feature alloc only.
impl ToOwned for Topic
Available on crate feature
alloc only.