Expand description
Serialize support for messagepack
§Limitation
MessagePack requires the length header of arrays and maps to be written before any elements are encoded.
When the alloc feature is disabled, this serializer therefore needs serde to provide the exact length up front.
If length is not provided, return Error::SeqLenNone.
With alloc feature, unknown-length sequences and maps are buffered until their final length is known.
This allows serializers that emit including serde(flatten).
use serde::Serialize;
#[derive(Serialize)]
struct Inner { b: u8, c: u8 }
#[derive(Serialize)]
struct Outer {
a: u8,
#[serde(flatten)]
extra: Inner,
}
let mut buf = [0u8; 32];
let v = Outer { a: 1, extra: Inner { b: 2, c: 3 } };
let res = messagepack_serde::ser::to_slice(&v, &mut buf);
#[cfg(feature = "alloc")]
assert!(res.is_ok());
#[cfg(not(feature = "alloc"))]
assert!(matches!(res, Err(messagepack_serde::ser::Error::SeqLenNone)));Structs§
- Aggressive
Minimize - Encode a given numeric value by aggressively minimising its format.
- Exact
- Encode a given numeric value exactly using its native format.
- Lossless
Minimize - Encode a given numeric value in a lossless minimised format without changing its original format.
Enums§
- Error
- Error during serialization
Traits§
- NumEncoder
- Decide how numeric values are encoded.
Functions§
- to_
core_ writer - Serialize value to messagepack_core::io::IoWrite.
- to_
core_ writer_ with_ config - Serialize value to messagepack_core::io::IoWrite with config.
- to_
slice - Serialize value to slice
- to_
slice_ with_ config - Serialize value to slice with config.
- to_vec
alloc - Serialize value as messagepack byte vector
- to_
vec_ with_ config alloc - Serialize value as messagepack byte vector with config
- to_
writer std - Serialize value to std::io::Write
- to_
writer_ with_ config std - Serialize value to std::io::Write with config.