The [`SubmitRejection`] an [`pb::ErrorInfo`] from [`rejection_error_info`] describes, if it is one.
(info: &pb::ErrorInfo)
| 292 | /// The [`SubmitRejection`] an [`pb::ErrorInfo`] from |
| 293 | /// [`rejection_error_info`] describes, if it is one. |
| 294 | pub fn rejection_from_error_info(info: &pb::ErrorInfo) -> Option<SubmitRejection> { |
| 295 | let get = |k: &str| info.context.get(k).cloned(); |
| 296 | Some(match info.context.get(REJECTION_REASON)?.as_str() { |
| 297 | "hash_mismatch" => SubmitRejection::HashMismatch { |
| 298 | claimed: get("claimed")?, |
| 299 | computed: get("computed")?, |
| 300 | }, |
| 301 | "malformed" => SubmitRejection::Malformed(get("detail")?), |
| 302 | "stale_view" => SubmitRejection::StaleView { |
| 303 | current: get("current")?, |
| 304 | }, |
| 305 | "foreign_change" => SubmitRejection::ForeignChange(get("change")?), |
| 306 | "foreign_node" => SubmitRejection::ForeignNode(get("node")?.parse().ok()?), |
| 307 | "forbidden_path" => SubmitRejection::ForbiddenPath(get("path")?), |
| 308 | "already_present" => SubmitRejection::AlreadyPresent(get("change")?), |
| 309 | _ => return None, |
| 310 | }) |
| 311 | } |
| 312 | |
| 313 | /// Envelope hint only. Core decoding still authenticates CODECS and the hash. |
| 314 | /// Historical payloads keep the legacy label; they are never upgraded here. |