xmtp_mls_core/api_status.rs
1/// The status the backend returned for a publish. A failed configuration
2/// check before dispatch sent nothing, so its status is not the backend's.
3pub fn backend_status(error: &xmtp_api::ApiError) -> Option<tonic::Code> {
4 if xmtp_api::preflight::failure(error).is_some() {
5 return None;
6 }
7 xmtp_proto::api::grpc_status(error).map(|status| status.code())
8}
9
10/// Only `INVALID_ARGUMENT` proves that an atomic publish stored nothing.
11/// Every other failure, including `OUT_OF_RANGE`, can follow a commit.
12pub fn definite_refusal(error: &xmtp_api::ApiError) -> bool {
13 backend_status(error) == Some(tonic::Code::InvalidArgument)
14}