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

Function root_row

atomic-repository/src/change_source/scan.rs:927–950  ·  view source on GitHub ↗
(
    entry: &CanonicalTrackedPath,
    change: VerifiedChange,
    content_id: Option<Hash>,
)

Source from the content-addressed store, hash-verified

925}
926
927fn root_row(
928 entry: &CanonicalTrackedPath,
929 change: VerifiedChange,
930 content_id: Option<Hash>,
931) -> Vec<u8> {
932 let mut bytes = Vec::new();
933 bytes.extend_from_slice(&(entry.path.as_bytes().len() as u64).to_le_bytes());
934 bytes.extend_from_slice(entry.path.as_bytes());
935 bytes.push(match change {
936 VerifiedChange::Unchanged => 0,
937 VerifiedChange::Modified => 1,
938 VerifiedChange::Deleted => 2,
939 VerifiedChange::TypeChanged => 3,
940 VerifiedChange::PermissionsChanged => 4,
941 });
942 bytes.extend_from_slice(&entry.canonical_mode.to_le_bytes());
943 bytes.push(entry.canonical_kind.as_byte());
944 if let Some(content_id) = content_id {
945 bytes.extend_from_slice(content_id.as_bytes());
946 } else {
947 bytes.extend_from_slice(&[0; 32]);
948 }
949 bytes
950}
951
952fn canonical_root_bytes(rows: &[Vec<u8>]) -> Vec<u8> {
953 let mut bytes = b"atomic.verified-candidates-v1\0".to_vec();

Callers 1

Calls 5

to_le_bytesMethod · 0.80
as_byteMethod · 0.80
lenMethod · 0.45
as_bytesMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected