The [`SubmitRejection`] an [`pb::ErrorInfo`] from [`rejection_error_info`] describes, if it is one.
(info: &pb::ErrorInfo)
| 287 | /// The [`SubmitRejection`] an [`pb::ErrorInfo`] from |
| 288 | /// [`rejection_error_info`] describes, if it is one. |
| 289 | pub 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 | |
| 308 | pub fn change_bundle(hash: &Hash, bytes: Vec<u8>) -> pb::ChangeBundle { |
| 309 | pb::ChangeBundle { |