Struct tokio_serde_cbor::Encoder
source · [−]pub struct Encoder<Item> { /* private fields */ }
Expand description
CBOR based encoder.
This encoder can be used with tokio_io
’s Framed
to encode CBOR frames. Anything
that is serde
s Serialize
can be encoded this way (at least in theory, some values return
errors when attempted to serialize).
Implementations
sourceimpl<Item: Serialize> Encoder<Item>
impl<Item: Serialize> Encoder<Item>
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new encoder.
By default, it doesn’t do packed encoding (it includes struct field names) and it doesn’t prefix the frames with self-describe tag.
sourcepub fn sd(self, sd: SdMode) -> Self
pub fn sd(self, sd: SdMode) -> Self
Turns the encoder into one with confifured self-describe behaviour.
sourcepub fn packed(self, packed: bool) -> Self
pub fn packed(self, packed: bool) -> Self
Turns the encoder into one with configured packed encoding.
If packed
is true, it omits the field names from the encoded data. That makes it smaller,
but it also means the decoding end must know the exact order of fields and it can’t be
something like python, which would want to get a dictionary out of it.