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§
Source§impl Topic
impl 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.
Source§impl Topic
impl Topic
Sourcepub fn try_to_owned(&self) -> Result<TopicBuf, TryReserveError>
pub fn try_to_owned(&self) -> Result<TopicBuf, TryReserveError>
Copies the topic into a TopicBuf without panicking if the
allocation fails.
§Errors
Returns TryReserveError if the allocation fails.
Trait Implementations§
impl Eq for Topic
impl StructuralPartialEq for Topic
Auto Trait Implementations§
impl !Sized for Topic
impl Freeze for Topic
impl RefUnwindSafe for Topic
impl Send for Topic
impl Sync for Topic
impl Unpin for Topic
impl UnsafeUnpin for Topic
impl UnwindSafe for Topic
Blanket Implementations§
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<K, Q> Equivalent<Q> for K
impl<K, Q> Equivalent<Q> for K
§fn equivalent(&self, key: &Q) -> bool
fn equivalent(&self, key: &Q) -> bool
key and return true if they are equal.