Encode any `Serialize` type as MessagePack bytes. Serializes via serde to an intermediate `serde_json::Value`, then converts to MessagePack. Use `encode()` for types that implement `ToMessagePack` directly (faster, no intermediate).
(
value: &T,
)
| 29 | /// to MessagePack. Use `encode()` for types that implement `ToMessagePack` |
| 30 | /// directly (faster, no intermediate). |
| 31 | pub(in crate::data::executor) fn encode_serde<T: serde::Serialize>( |
| 32 | value: &T, |
| 33 | ) -> crate::Result<Vec<u8>> { |
| 34 | let json_value = serde_json::to_value(value).map_err(|e| crate::Error::Codec { |
| 35 | detail: format!("serde serialization: {e}"), |
| 36 | })?; |
| 37 | encode_json(&json_value) |
| 38 | } |
| 39 | |
| 40 | /// Encode a Vec of serde_json::Value as MessagePack bytes. |
| 41 | pub(in crate::data::executor) fn encode_json_vec( |
no test coverage detected