GrpcStatus
struct GrpcStatusAn RPC outcome: numeric code + optional human message + optional binary detail.
Status codes are stable across implementations -- a Mojo
handler returning GRPC_STATUS_NOT_FOUND will surface as
the same code in a Go / Python / C++ client. The optional
message carries free-text context for diagnostics; it
must not be used for branching by the client.
details carries the optional grpc-status-details-bin
payload (RFC 4648 §4 base64 on the wire; opaque bytes here so
the application can attach a serialised
google.rpc.Status proto, a typed error envelope, or any
other binary frame the client knows how to parse).
Implements Copyable, Movable
- Fields
code: Intmessage: Stringdetails: Optional[List[UInt8]]
comptime OK = Int(0)comptime CANCELLED = Int(1)comptime UNKNOWN = Int(2)comptime INVALID_ARGUMENT = Int(3)comptime DEADLINE_EXCEEDED = Int(4)comptime NOT_FOUND = Int(5)comptime ALREADY_EXISTS = Int(6)comptime PERMISSION_DENIED = Int(7)comptime RESOURCE_EXHAUSTED = Int(8)comptime FAILED_PRECONDITION = Int(9)comptime ABORTED = Int(10)comptime OUT_OF_RANGE = Int(11)comptime UNIMPLEMENTED = Int(12)comptime INTERNAL = Int(13)comptime UNAVAILABLE = Int(14)comptime DATA_LOSS = Int(15)comptime UNAUTHENTICATED = Int(16)ok
def ok() -> Self err
def err(code: Int, message: String) -> Self with_details
def with_details(self, var details: List[UInt8]) -> Self Return a copy of this status with the grpc-status- details-bin payload attached. The caller owns the bytes; the trailer emitter base64-encodes them when serialising the trailing HEADERS field set.
is_ok
def is_ok(self) -> Bool name
def name(self) -> String Return the canonical short name for the status code. Unknown numeric codes (outside 0..16) return "UNKNOWN_CODE_<n>" so logs always have something to grep for.