Serialize `value` with postcard and zstd-compress it into a wire body. Deterministic for a given value (postcard field order is fixed and zstd is deterministic at a fixed level), which keeps request bodies reproducible for tests and caches.
(value: &T)
| 296 | /// deterministic at a fixed level), which keeps request bodies reproducible for |
| 297 | /// tests and caches. |
| 298 | pub fn encode<T: Serialize>(value: &T) -> Result<Vec<u8>, SyncError> { |
| 299 | let raw = postcard::to_allocvec(value).map_err(SyncError::Codec)?; |
| 300 | zstd::encode_all(raw.as_slice(), DEFAULT_ZSTD_LEVEL).map_err(SyncError::Compression) |
| 301 | } |
| 302 | |
| 303 | /// Decompress and deserialize a wire body, bounded by |
| 304 | /// [`DEFAULT_MAX_DECOMPRESSED`]. Use [`decode_with_limit`] to set a tighter cap |
no test coverage detected