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

Function scan_token

atomic-repository/src/change_source/scan.rs:656–672  ·  view source on GitHub ↗
(candidates: &[ChangeCandidate])

Source from the content-addressed store, hash-verified

654}
655
656fn scan_token(candidates: &[ChangeCandidate]) -> ChangeSourceToken {
657 let mut bytes = b"atomic.scan-token-v1\0".to_vec();
658 for candidate in candidates {
659 bytes.extend_from_slice(&(candidate.path.as_bytes().len() as u64).to_le_bytes());
660 bytes.extend_from_slice(candidate.path.as_bytes());
661 match &candidate.observation {
662 CandidateObservation::Missing => bytes.push(0),
663 CandidateObservation::Present(file) => {
664 bytes.push(1);
665 bytes.extend_from_slice(&file.device.unwrap_or(u64::MAX).to_le_bytes());
666 bytes.extend_from_slice(&file.inode.unwrap_or(u64::MAX).to_le_bytes());
667 bytes.extend_from_slice(&file.size.to_le_bytes());
668 }
669 }
670 }
671 ChangeSourceToken(Hash::of(&bytes).as_bytes().to_vec())
672}
673
674fn canonical_kind(kind: ObservedKind) -> Option<InodeKind> {
675 match kind {

Callers 1

changes_with_providerMethod · 0.85

Calls 5

ChangeSourceTokenClass · 0.85
to_le_bytesMethod · 0.80
lenMethod · 0.45
as_bytesMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected