Skip to main content

map_command_status

Function map_command_status 

pub fn map_command_status(status: &Status) -> Error
Expand description

Status of a command (place / cancel / replace). Only statuses that prove the broker did not act become Rejected; anything that can hide a processed request is Unknown.

The statuses that prove the broker did not act (ResourceExhausted, InvalidArgument, NotFound, PermissionDenied, Unauthenticated, FailedPrecondition, Unimplemented, AlreadyExists, OutOfRange) are mapped like in map_status. Every other status (DeadlineExceeded, Unavailable, Internal, Aborted, Cancelled, Unknown, …) is [Error::Unknown], because the request may have been processed before the answer was lost. Do not repeat the command after it: ask the broker for the order first.

§Examples

use brokapi_core::Error;
use brokapi_tbank::error::map_command_status;
use tonic::Status;

assert!(matches!(map_command_status(&Status::unavailable("reset")), Error::Unknown));
assert!(matches!(map_command_status(&Status::not_found("50005")), Error::Rejected { .. }));