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

Function rejection_from_error_info

libatomic/src/daemon/sandbox_wire.rs:289–306  ·  view source on GitHub ↗

The [`SubmitRejection`] an [`pb::ErrorInfo`] from [`rejection_error_info`] describes, if it is one.

(info: &pb::ErrorInfo)

Source from the content-addressed store, hash-verified

287/// The [`SubmitRejection`] an [`pb::ErrorInfo`] from
288/// [`rejection_error_info`] describes, if it is one.
289pub fn rejection_from_error_info(info: &pb::ErrorInfo) -> Option<SubmitRejection> {
290 let get = |k: &str| info.context.get(k).cloned();
291 Some(match info.context.get(REJECTION_REASON)?.as_str() {
292 "hash_mismatch" => SubmitRejection::HashMismatch {
293 claimed: get("claimed")?,
294 computed: get("computed")?,
295 },
296 "malformed" => SubmitRejection::Malformed(get("detail")?),
297 "stale_view" => SubmitRejection::StaleView {
298 current: get("current")?,
299 },
300 "foreign_change" => SubmitRejection::ForeignChange(get("change")?),
301 "foreign_node" => SubmitRejection::ForeignNode(get("node")?.parse().ok()?),
302 "forbidden_path" => SubmitRejection::ForbiddenPath(get("path")?),
303 "already_present" => SubmitRejection::AlreadyPresent(get("change")?),
304 _ => return None,
305 })
306}
307
308pub fn change_bundle(hash: &Hash, bytes: Vec<u8>) -> pb::ChangeBundle {
309 pb::ChangeBundle {

Callers 6

submitMethod · 0.85
publish_provenanceMethod · 0.85
submit_attestationMethod · 0.85
submitMethod · 0.85
publish_provenanceMethod · 0.85
submit_attestationMethod · 0.85

Calls 5

getMethod · 0.65
getFunction · 0.50
as_strMethod · 0.45
okMethod · 0.45
parseMethod · 0.45

Tested by 3

submitMethod · 0.68
publish_provenanceMethod · 0.68
submit_attestationMethod · 0.68