pub struct TextSerializer;Expand description
Text serializer for bare Display/FromStr payloads.
Serializes a value to its Display string and parses it back with
FromStr, carrying the bare value on the wire (21.5, ON, 255,0,0)
rather than a framed struct. This is the shape most non-Rust MQTT systems
(Home Assistant, Tasmota, Homie, Zigbee2MQTT) speak — where JsonSerializer
would quote strings ("21.5") and BincodeSerializer would length-prefix.
It reuses the exact Display/FromStr pair that topic parameters already
use, so String, all numbers, bool, and any user type that formats as a
delimited token (e.g. a Color printing r,g,b) round-trip as bare text.
deserialize trims surrounding whitespace before parsing, so a trailing
newline appended on the wire (b"21.5\n") still parses. Note the resulting
asymmetry for String payloads: a value with leading/trailing spaces does
not round-trip (" hi " deserializes back to "hi").
Always available — pulls no extra dependency.
Implementations§
Source§impl TextSerializer
impl TextSerializer
Sourcepub fn new() -> TextSerializer
pub fn new() -> TextSerializer
Creates a new text serializer.
Trait Implementations§
Source§impl Clone for TextSerializer
impl Clone for TextSerializer
Source§fn clone(&self) -> TextSerializer
fn clone(&self) -> TextSerializer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more