Generic encoders for Data Plane response payloads, plus the `decode_payload_to_json` transcoder used at the Control Plane boundary. Serialize a response payload as MessagePack bytes. Drop-in replacement for `serde_json::to_vec(&value)` in handler code. Returns MessagePack bytes that are 30-50% smaller and 2-3x faster to produce than JSON.
(
value: &T,
)
| 9 | /// Returns MessagePack bytes that are 30-50% smaller and 2-3x faster to |
| 10 | /// produce than JSON. |
| 11 | pub(in crate::data::executor) fn encode<T: zerompk::ToMessagePack>( |
| 12 | value: &T, |
| 13 | ) -> crate::Result<Vec<u8>> { |
| 14 | zerompk::to_msgpack_vec(value).map_err(|e| crate::Error::Codec { |
| 15 | detail: format!("response serialization: {e}"), |
| 16 | }) |
| 17 | } |
| 18 | |
| 19 | /// Encode a serde_json::Value payload as MessagePack bytes. |
| 20 | pub(in crate::data::executor) fn encode_json(value: &serde_json::Value) -> crate::Result<Vec<u8>> { |
no outgoing calls