saas-rs-sdk 0.6.3

The SaaS RS SDK
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use tonic::Code;

pub fn grpc_code_from_http_status_code(http_status_code: &str) -> Code {
    match http_status_code {
        "200" => Code::Ok,
        "302" => Code::AlreadyExists,
        "400" | "411" | "414" => Code::InvalidArgument,
        "401" | "407" => Code::Unauthenticated,
        "404" | "410" => Code::NotFound,
        "408" | "504" => Code::DeadlineExceeded,
        "402" | "409" | "412" | "417" | "423" => Code::FailedPrecondition,
        "416" => Code::OutOfRange,
        "500" => Code::Internal,
        "501" => Code::Unimplemented,
        "503" => Code::Unavailable,
        _ => Code::Unknown,
    }
}