pub struct StringData(/* private fields */);Expand description
Text fields within the MQTT Control Packets described later are encoded as UTF-8 strings. UTF-8 RFC3629 is an efficient encoding of Unicode Unicode characters that optimizes the encoding of ASCII characters in support of text-based communications.
String Data is represented by a Two Byte Integer length which indicates the number of data bytes, followed by characters.
Thus, the length of String Data is limited to the range of 0 to 65,535 Bytes.
+-------------------+
| String Length |
| |
+-------------------+
| String |
| |
+-------------------+The character data in a UTF-8 Encoded String MUST be well-formed UTF-8 as defined by the Unicode specification Unicode and restated in RFC 3629 RFC3629. In particular, the character data MUST NOT include encodings of code points between U+D800 and U+DFFF [MQTT-1.5.4-1].
If the Client or Server receives an MQTT Control Packet containing ill-formed UTF-8 it is a Malformed Packet.
A UTF-8 Encoded String MUST NOT include an encoding of the null character U+0000. [MQTT-1.5.4-2].
If a receiver (Server or Client) receives an MQTT Control Packet containing U+0000 it is a Malformed Packet.
The data SHOULD NOT include encodings of the Unicode Unicode code points listed below. If a receiver (Server or Client) receives an MQTT Control Packet containing any of them it MAY treat it as a Malformed Packet. These are the Disallowed Unicode code points.
- U+0001..U+001F control characters
- U+007F..U+009F control characters
- Code points defined in the Unicode specification Unicode to be non-characters (for example U+0FFFF)
A UTF-8 encoded sequence 0xEF 0xBB 0xBF is always interpreted as U+FEFF (“ZERO WIDTH NO-BREAK SPACE”) wherever it appears in a string and MUST NOT be skipped over or stripped off by a packet receiver [MQTT-1.5.4-3].
Implementations§
Source§impl StringData
impl StringData
Sourcepub fn from(s: &str) -> Result<Self, StringError>
pub fn from(s: &str) -> Result<Self, StringError>
Trait Implementations§
Source§impl AsRef<str> for StringData
impl AsRef<str> for StringData
Source§impl Clone for StringData
impl Clone for StringData
Source§fn clone(&self) -> StringData
fn clone(&self) -> StringData
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more