pub enum ErrorKind {
Show 17 variants
ParseError,
InvalidRequest,
MethodNotFound,
InvalidParams,
Internal,
UnsupportedVersion,
CapabilityRequired,
DeadlineExceeded,
Cancelled,
Unavailable,
PermissionDenied,
InteractionRequired,
Conflict,
OperationFailed,
MessageTooLarge,
RepresentationMismatch,
Unrecognized,
}Expand description
Stable machine-readable error kinds shared by both application protocols.
The set is closed for senders and open for receivers. An endpoint emits only
the kinds below, but a receiver decodes anything it does not recognize as
ErrorKind::Unrecognized instead of failing the frame. Without that, the
first kind a later protocol version adds would kill every session with an
older peer, and the set could never grow without a new protocol version.
Variants§
ParseError
InvalidRequest
MethodNotFound
InvalidParams
Internal
UnsupportedVersion
CapabilityRequired
DeadlineExceeded
Cancelled
PermissionDenied
InteractionRequired
Conflict
OperationFailed
MessageTooLarge
RepresentationMismatch
Unrecognized
A kind this implementation does not know, decoded from a peer that speaks a later revision of the protocol.
Receiving one means the operation failed for a reason this side cannot
name, so it is handled as a failure and never as a success. An endpoint
MUST NOT construct it: doing so would put "unrecognized" on the wire
as if it were a defined kind.
Implementations§
Source§impl ErrorKind
impl ErrorKind
Sourcepub const DEFINED: &'static [Self]
pub const DEFINED: &'static [Self]
Every kind this revision defines, in wire-code order. Unrecognized is
deliberately absent: it is a decoding outcome, not a defined kind.
Sourcepub const fn as_str(self) -> &'static str
pub const fn as_str(self) -> &'static str
Stable wire spelling used for structured handling and redacted audit records.
Sourcepub fn from_wire(kind: &str) -> Self
pub fn from_wire(kind: &str) -> Self
Decode a wire spelling, mapping anything unknown to
Self::Unrecognized rather than refusing the frame.
Sourcepub fn from_code(code: i32) -> Option<Self>
pub fn from_code(code: i32) -> Option<Self>
The kind a defined code names, or None for a code this revision does
not define. Used to keep a peer honest: a code this side knows must
arrive with the kind that belongs to it, and only a code it does not
know may carry a kind it does not know.