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

Method serialize

atomic-core/src/change/provenance_graph/mod.rs:253–262  ·  view source on GitHub ↗

Serialize the provenance graph 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

251 ///
252 /// The hash is computed over the entire serialized output.
253 pub fn serialize(&self) -> Result<Vec<u8>, ProvenanceGraphError> {
254 let payload = postcard::to_allocvec(self).map_err(|e| ProvenanceGraphError::Codec {
255 reason: format!("postcard serialize failed: {}", e),
256 })?;
257
258 let mut buf = Vec::with_capacity(MAGIC.len() + payload.len());
259 buf.extend_from_slice(MAGIC);
260 buf.extend_from_slice(&payload);
261 Ok(buf)
262 }
263
264 /// Deserialize a provenance graph from bytes, returning the graph and its hash.
265 ///

Calls 1

lenMethod · 0.45