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

Function atom_change_file_version

atomic-repository/src/repository/changes.rs:13–26  ·  view source on GitHub ↗
(bytes: &[u8])

Source from the content-addressed store, hash-verified

11 atomic_core::change::format_v3::FIELD_CODEC_FORMAT_VERSION;
12
13fn atom_change_file_version(bytes: &[u8]) -> Result<u32, RepositoryError> {
14 if bytes.len() < ATOM_CHANGE_FILE_HEADER_LEN {
15 return Err(RepositoryError::Serialization(format!(
16 "change object is too short for an ATOM file header: expected at least {ATOM_CHANGE_FILE_HEADER_LEN} bytes, found {}",
17 bytes.len()
18 )));
19 }
20 if &bytes[..4] != ATOM_CHANGE_MAGIC {
21 return Err(RepositoryError::Serialization(
22 "change object does not begin with ATOM file-header magic".to_string(),
23 ));
24 }
25 Ok(u32::from_le_bytes([bytes[4], bytes[5], bytes[6], bytes[7]]))
26}
27
28impl Repository {
29 pub(super) fn fence_legacy_span_storage(&self, change: &Change) -> Result<(), RepositoryError> {

Calls 1

lenMethod · 0.45

Tested by

no test coverage detected