MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / encode

Function encode

atomic-objects/src/sync.rs:298–301  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

296/// deterministic at a fixed level), which keeps request bodies reproducible for
297/// tests and caches.
298pub 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

Callers 2

encode_proof_valueFunction · 0.85
encodeMethod · 0.85

Calls 1

as_sliceMethod · 0.45

Tested by

no test coverage detected