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§
Source§impl Topic
impl Topic
Sourcepub const unsafe fn new_unchecked(s: &MqttStr) -> &Topic
pub const unsafe fn new_unchecked(s: &MqttStr) -> &Topic
Sourcepub const fn new(s: &MqttStr) -> Result<&Topic, TopicError>
pub const fn new(s: &MqttStr) -> Result<&Topic, 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 (+, #).
Sourcepub const fn as_mqtt_str(&self) -> &MqttStr
pub const fn as_mqtt_str(&self) -> &MqttStr
View the topic as an MqttStr.
Trait Implementations§
Source§impl ToOwned for Topic
impl ToOwned for Topic
impl Eq for Topic
impl StructuralPartialEq for Topic
Auto Trait Implementations§
impl Freeze for Topic
impl RefUnwindSafe for Topic
impl Send for Topic
impl !Sized for Topic
impl Sync for Topic
impl Unpin for Topic
impl UnwindSafe for Topic
Blanket Implementations§
§impl<T> AsUncased for T
impl<T> AsUncased for T
§fn as_uncased(&self) -> &UncasedStr
fn as_uncased(&self) -> &UncasedStr
Convert
self to an [UncasedStr].Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more