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
Create 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>
Validate and wrap 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 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