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

Method decode

atomic-core/src/pristine/file_index_v2.rs:80–96  ·  view source on GitHub ↗
(bytes: &[u8])

Source from the content-addressed store, hash-verified

78 }
79
80 pub fn decode(bytes: &[u8]) -> PristineResult<Self> {
81 if bytes.len() <= KEY_HEADER_SIZE {
82 return Err(codec_error("FILE_INDEX_V2 key is truncated"));
83 }
84 if bytes[0] != FILE_INDEX_V2_KEY_VERSION {
85 return Err(codec_error(format!(
86 "unsupported FILE_INDEX_V2 key version {}",
87 bytes[0]
88 )));
89 }
90 let working_copy = WorkingCopyId::from_bytes(
91 bytes[1..KEY_HEADER_SIZE]
92 .try_into()
93 .map_err(|_| codec_error("FILE_INDEX_V2 working-copy key is malformed"))?,
94 );
95 Self::new(working_copy, bytes[KEY_HEADER_SIZE..].to_vec())
96 }
97}
98
99/// Filesystem identity and canonical graph facts cached for one path.

Callers

nothing calls this directly

Calls 2

codec_errorFunction · 0.70
lenMethod · 0.45

Tested by

no test coverage detected