Verify the original V3 bytes, section manifest and decoded semantics. The original encoded identity is authoritative; no recompression is needed.
(bytes: &[u8])
| 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> { |
nothing calls this directly
no test coverage detected