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§
§impl MqttStr
impl MqttStr
pub const EMPTY: &'static Self
pub const EMPTY: &'static Self
The empty MQTT string.
pub const unsafe fn new_unchecked(s: &str) -> &Self
pub const unsafe fn new_unchecked(s: &str) -> &Self
Create a new MQTT string without validating MQTT-specific invariants.
§Safety
The caller must guarantee that s satisfies the MQTT string invariants.
pub const fn new(s: &str) -> Result<&Self, DataError>
pub const fn new(s: &str) -> Result<&Self, DataError>
Validate and wrap a &str.
§Errors
Returns DataError::TooLong if s exceeds 65 535 bytes, or
DataError::ContainsNull if s contains U+0000.
pub const fn as_mqtt_bytes(&self) -> &MqttBytes
pub const fn as_mqtt_bytes(&self) -> &MqttBytes
Returns this string as MqttBytes.
pub 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§
§impl AsRef<MqttStr> for MqttString
Available on crate feature alloc only.
impl AsRef<MqttStr> for MqttString
Available on crate feature
alloc only.§impl AsRef<MqttStr> for TopicFilter
impl AsRef<MqttStr> for TopicFilter
§impl AsRef<MqttStr> for TopicFilterBuf
Available on crate feature alloc only.
impl AsRef<MqttStr> for TopicFilterBuf
Available on crate feature
alloc only.§impl Borrow<MqttStr> for MqttString
Available on crate feature alloc only.
impl Borrow<MqttStr> for MqttString
Available on crate feature
alloc only.§impl ToOwned for MqttStr
Available on crate feature alloc only.
impl ToOwned for MqttStr
Available on crate feature
alloc only.§type Owned = MqttString
type Owned = MqttString
The resulting type after obtaining ownership.
§fn to_owned(&self) -> Self::Owned
fn to_owned(&self) -> Self::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