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

Function hash_from_proto

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

Source from the content-addressed store, hash-verified

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

Callers 9

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