Skip to main content

Code

Enum Code 

Source
#[repr(u8)]
pub enum Code {
Show 17 variants Ok = 0, Cancelled = 1, Unknown = 2, InvalidArgument = 3, DeadlineExceeded = 4, NotFound = 5, AlreadyExists = 6, PermissionDenied = 7, ResourceExhausted = 8, FailedPrecondition = 9, Aborted = 10, OutOfRange = 11, Unimplemented = 12, Internal = 13, Unavailable = 14, DataLoss = 15, Unauthenticated = 16,
}
Expand description

A gRPC status code — the integer carried in the grpc-status trailer.

The discriminants are the canonical gRPC code numbers, so as u8 and from_u8 move between the enum and its wire form. Ok (0) is the success code; every other variant is an error.

Variants§

§

Ok = 0

Not an error; the RPC completed successfully.

§

Cancelled = 1

The operation was cancelled, typically by the caller.

§

Unknown = 2

An error whose cause doesn’t map to a more specific code. Also the code a missing or unparseable grpc-status resolves to.

§

InvalidArgument = 3

The client supplied an argument the server could not accept (as opposed to FailedPrecondition, this is independent of system state).

§

DeadlineExceeded = 4

The deadline expired before the operation could complete.

§

NotFound = 5

A requested entity was not found.

§

AlreadyExists = 6

An entity the client tried to create already exists.

§

PermissionDenied = 7

The caller is authenticated but lacks permission for this operation.

§

ResourceExhausted = 8

A resource has been exhausted — a quota, or perhaps the message-size limit.

§

FailedPrecondition = 9

The system is not in a state required for the operation (e.g. acting on a resource that must first be initialized).

§

Aborted = 10

The operation was aborted, often due to a concurrency conflict.

§

OutOfRange = 11

The operation was attempted past the valid range.

§

Unimplemented = 12

The operation is not implemented or not supported. Also the code a 404 from the transport maps to.

§

Internal = 13

An internal invariant was broken — something the implementation expected to hold did not.

§

Unavailable = 14

The service is unavailable, typically a transient condition the caller can retry with backoff.

§

DataLoss = 15

Unrecoverable data loss or corruption.

§

Unauthenticated = 16

The request lacks valid authentication credentials.

Implementations§

Source§

impl Code

Source

pub fn from_u8(n: u8) -> Option<Self>

Convert a wire byte to a Code, or None if it isn’t one of the 0–16 gRPC codes.

Source

pub const fn as_u8(self) -> u8

The canonical gRPC code number, as written into the grpc-status trailer.

Trait Implementations§

Source§

impl Clone for Code

Source§

fn clone(&self) -> Code

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Code

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for Code

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Code

Source§

fn eq(&self, other: &Code) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Code

Source§

impl Eq for Code

Source§

impl StructuralPartialEq for Code

Auto Trait Implementations§

§

impl Freeze for Code

§

impl RefUnwindSafe for Code

§

impl Send for Code

§

impl Sync for Code

§

impl Unpin for Code

§

impl UnsafeUnpin for Code

§

impl UnwindSafe for Code

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Server for T
where T: 'static,

Source§

async fn unary<Req, Resp>( conn: Conn, f: impl AsyncFnOnce(&mut GrpcServerConn<Self>, Req) -> Result<Resp, Status>, ) -> Conn
where Self: Codec<Req> + Codec<Resp>, Req: Send + 'static, Resp: Send + 'static,

Unary RPC: read exactly one request, await the user function, emit one response frame followed by grpc-status trailers.
Source§

async fn client_streaming<Resp>( conn: Conn, f: impl AsyncFnOnce(&mut GrpcServerConn<Self>) -> Result<Resp, Status>, ) -> Conn
where Self: Codec<Resp>, Resp: Send + 'static,

Client-streaming RPC: hand the user a GrpcServerConn from which they read the request stream (conn.requests::<Req>()); emit the single response frame and grpc-status trailers.
Source§

async fn server_streaming<Req, Resp, S>( conn: Conn, f: impl AsyncFnOnce(&mut GrpcServerConn<Self>, Req) -> Result<S, Status>, ) -> Conn
where Self: Codec<Req> + Codec<Resp>, Req: Send + 'static, Resp: Send + 'static, S: Stream<Item = Result<Resp, Status>> + Send + 'static,

Server-streaming RPC: read one request, await the user function for a response Stream, then frame each item lazily into the response body with grpc-status trailers derived from how the stream ended.
Source§

async fn bidi<Req, Resp, R>( conn: Conn, prologue: impl AsyncFnOnce(&mut GrpcServerConn<Self>) -> Result<R, Status>, ) -> Conn
where Self: Codec<Req> + Codec<Resp>, Req: Send + 'static, Resp: Send + 'static, R: BidiResponder<Req, Resp>,

Bidirectional-streaming RPC — the run-phase prologue. Hand the user a GrpcServerConn from which they may read early request messages (to decide response headers) and set initial metadata, then return a BidiResponder that drives the read-while-write loop after the head is flushed. Returning Err(Status) rejects before the flush (trailers-only, no upgrade). See crate::server::bidi for the seam mechanics.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.