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

Method serialize

atomic-core/src/change/attestation.rs:394–403  ·  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

392 ///
393 /// The hash is computed over the entire serialized output.
394 pub fn serialize(&self) -> Result<Vec<u8>, AttestationError> {
395 let payload = postcard::to_allocvec(self).map_err(|e| AttestationError::Codec {
396 reason: format!("postcard serialize failed: {}", e),
397 })?;
398
399 let mut buf = Vec::with_capacity(MAGIC.len() + payload.len());
400 buf.extend_from_slice(MAGIC);
401 buf.extend_from_slice(&payload);
402 Ok(buf)
403 }
404
405 /// Deserialize an attestation from bytes, returning the attestation and its hash.
406 ///

Calls 1

lenMethod · 0.45

Tested by

no test coverage detected