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. A topic name must be a non-empty MqttStr without wildcard
characters (+, #). An MqttStr is at most 65 535 bytes and does not
contain 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(super) const fn from_validated(s: &MqttStr) -> &Self
pub(super) const fn from_validated(s: &MqttStr) -> &Self
Wraps s, which the caller has already validated.
pub const fn new(s: &MqttStr) -> Result<&Self, TopicError>
pub const fn new(s: &MqttStr) -> Result<&Self, TopicError>
Validates and creates 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.
§impl Topic
impl Topic
pub fn try_to_owned(&self) -> Result<TopicBuf, TryReserveError>
Available on crate feature alloc only.
pub fn try_to_owned(&self) -> Result<TopicBuf, TryReserveError>
alloc only.Copies the topic into a TopicBuf without panicking if the
allocation fails.
§Errors
Returns TryReserveError if the allocation fails.