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

Method from_bytes

atomic-core/src/change/verified.rs:21–34  ·  view source on GitHub ↗

Verify the original V3 bytes, section manifest and decoded semantics. The original encoded identity is authoritative; no recompression is needed.

(bytes: &[u8])

Source from the content-addressed store, hash-verified

19 /// Verify the original V3 bytes, section manifest and decoded semantics.
20 /// The original encoded identity is authoritative; no recompression is needed.
21 pub fn from_bytes(bytes: &[u8]) -> Result<Self, ChangeError> {
22 let mut reader = Cursor::new(bytes);
23 let (change, hash) = Change::deserialize(&mut reader)?;
24 if reader.position() != bytes.len() as u64 {
25 return Err(ChangeError::Invalid(
26 "trailing bytes after verified change".into(),
27 ));
28 }
29 Ok(Self {
30 hash,
31 change: Arc::new(change),
32 source_digest: Some(Hash::of(bytes)),
33 })
34 }
35
36 /// Conservative fallback for stores that only provide decoded values.
37 pub fn from_change(change: Change) -> Result<Self, ChangeError> {

Callers

nothing calls this directly

Calls 3

deserializeFunction · 0.50
positionMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected