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

Method serialize

atomic-core/src/change/attestation.rs:193–202  ·  view source on GitHub ↗

Serialize the attestation to bytes. Format: `[MAGIC: 4 bytes][postcard payload]` The hash is computed over the entire serialized output.

(&self)

Source from the content-addressed store, hash-verified

191 ///
192 /// The hash is computed over the entire serialized output.
193 pub fn serialize(&self) -> Result<Vec<u8>, AttestationError> {
194 let payload = postcard::to_allocvec(self).map_err(|e| AttestationError::Codec {
195 reason: format!("postcard serialize failed: {}", e),
196 })?;
197
198 let mut buf = Vec::with_capacity(MAGIC.len() + payload.len());
199 buf.extend_from_slice(MAGIC);
200 buf.extend_from_slice(&payload);
201 Ok(buf)
202 }
203
204 /// Deserialize an attestation from bytes, returning the attestation and its hash.
205 ///

Callers 7

write_toMethod · 0.45
test_serialize_has_magicFunction · 0.45
test_hash_deterministicFunction · 0.45
test_minimal_roundtripFunction · 0.45

Calls 1

lenMethod · 0.45

Tested by

no test coverage detected