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

Function hash_from_proto

libatomic/src/daemon/sandbox_wire.rs:37–48  ·  view source on GitHub ↗
(hash: Option<&pb::Hash>)

Source from the content-addressed store, hash-verified

35pub const REJECTION_REASON: &str = "reason";
36
37pub fn hash_from_proto(hash: Option<&pb::Hash>) -> Result<Hash, String> {
38 let hash = hash.ok_or("hash is required")?;
39 if hash.algorithm != pb::HashAlgorithm::Blake3 as i32 && hash.algorithm != 0 {
40 return Err("only blake3 hashes are accepted".to_string());
41 }
42 let bytes: [u8; 32] = hash
43 .value
44 .as_slice()
45 .try_into()
46 .map_err(|_| "a hash is exactly 32 bytes".to_string())?;
47 Ok(Hash::from_bytes(bytes))
48}
49
50fn versioned(schema: &str, payload: Vec<u8>) -> pb::VersionedBytes {
51 pb::VersionedBytes {

Callers 8

submit_attestationMethod · 0.85
check_record_fenceFunction · 0.85
check_view_fenceFunction · 0.85
snapshot_fenceFunction · 0.85
slice_from_protoFunction · 0.85
change_from_bundleFunction · 0.85
get_changesMethod · 0.85
submit_attestationMethod · 0.85

Calls 1

as_sliceMethod · 0.45

Tested by 1

submit_attestationMethod · 0.68