Skip to main content

to_msgpack_bytes

Function to_msgpack_bytes 

Source
pub fn to_msgpack_bytes(value: &Value) -> Result<Bytes, CodecError>
Available on crate feature transport only.
Expand description

Serialise a MsgPack value to bytes via NATIVE rmpv::encode::write_value.

The inverse of the MsgPack arm of parse. This is the native rmpv encoder – NOT rmp_serde, NOT a JSON bridge. A transform that mutates a parsed rmpv::Value re-emits MsgPack wire bytes with a single native encode, no intermediate serde_json::Value, no re-parse.

§Errors

Returns CodecError::Encode if the encoder fails to write the value. For an in-memory Vec writer this is effectively unreachable, but the encoder is fallible so the error is surfaced rather than unwrapped.