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

Method canonical_bytes

atomic-repository/src/repository/conflict_object.rs:278–287  ·  view source on GitHub ↗

Canonical bytes: magic + version + deterministic postcard payload of the normalized (store-independent) object.

(&self)

Source from the content-addressed store, hash-verified

276 /// Canonical bytes: magic + version + deterministic postcard payload of
277 /// the normalized (store-independent) object.
278 pub fn canonical_bytes(&self) -> Result<Vec<u8>, ConflictObjectError> {
279 let normalized = self.normalized();
280 let mut bytes = Vec::with_capacity(64);
281 bytes.extend_from_slice(CONFLICT_SET_MAGIC);
282 bytes.extend_from_slice(&normalized.version.to_le_bytes());
283 let payload = postcard::to_allocvec(&normalized)
284 .map_err(|error| ConflictObjectError::Encode(error.to_string()))?;
285 bytes.extend_from_slice(&payload);
286 Ok(bytes)
287 }
288
289 /// Decode canonical bytes, failing closed on unknown versions.
290 pub fn decode(bytes: &[u8]) -> Result<Self, ConflictObjectError> {

Callers 5

hashMethod · 0.45
wrong_magic_fails_closedFunction · 0.45
zombie_base_roundtripsFunction · 0.45

Calls 2

normalizedMethod · 0.80
to_le_bytesMethod · 0.80