Struct MqttStr
#[repr(transparent)]pub struct MqttStr(str);Expand description
A UTF-8 string that satisfies all MQTT v5 requirements:
- Well-formed UTF-8 (guaranteed by Rust’s
str) - No surrogate code points U+D800..U+DFFF (guaranteed by Rust’s
str) - No null character U+0000 [MQTT-1.5.4-2]
- At most 65 535 bytes
This is an unsized type like str. Use &MqttStr for borrowed
references and MqttString for owned values.
Tuple Fields§
§0: strImplementations§
Source§impl MqttStr
impl MqttStr
Sourcepub const unsafe fn new_unchecked(s: &str) -> &MqttStr
pub const unsafe fn new_unchecked(s: &str) -> &MqttStr
Creates a new MQTT string without validating MQTT-specific invariants.
§Safety
The caller must guarantee that s satisfies the MQTT string invariants.
Sourcepub const fn new(s: &str) -> Result<&MqttStr, DataError>
pub const fn new(s: &str) -> Result<&MqttStr, DataError>
Validates and wraps a &str.
§Errors
Returns DataError::TooLong if s exceeds 65 535 bytes, or
DataError::ContainsNull if s contains U+0000.
Sourcepub const fn as_mqtt_bytes(&self) -> &MqttBytes
pub const fn as_mqtt_bytes(&self) -> &MqttBytes
Returns this string as MqttBytes.
Sourcepub const fn encoded_len(&self) -> usize
pub const fn encoded_len(&self) -> usize
Returns the number of bytes needed to encode this value.
Trait Implementations§
Source§impl AsRef<MqttStr> for MqttString
impl AsRef<MqttStr> for MqttString
Source§impl AsRef<MqttStr> for TopicFilter
impl AsRef<MqttStr> for TopicFilter
Source§impl AsRef<MqttStr> for TopicFilterBuf
impl AsRef<MqttStr> for TopicFilterBuf
Source§impl Borrow<MqttStr> for MqttString
impl Borrow<MqttStr> for MqttString
Source§impl PartialOrd for MqttStr
impl PartialOrd for MqttStr
Source§impl ToOwned for MqttStr
impl ToOwned for MqttStr
Source§type Owned = MqttString
type Owned = MqttString
The resulting type after obtaining ownership.
Source§fn to_owned(&self) -> <MqttStr as ToOwned>::Owned
fn to_owned(&self) -> <MqttStr as ToOwned>::Owned
Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · Source§fn clone_into(&self, target: &mut Self::Owned)
fn clone_into(&self, target: &mut Self::Owned)
Uses borrowed data to replace owned data, usually by cloning. Read more
impl Eq for MqttStr
impl StructuralPartialEq for MqttStr
Auto Trait Implementations§
impl Freeze for MqttStr
impl RefUnwindSafe for MqttStr
impl Send for MqttStr
impl !Sized for MqttStr
impl Sync for MqttStr
impl Unpin for MqttStr
impl UnwindSafe for MqttStr
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