Enum ockam_core::errcode::Kind

source ·
#[non_exhaustive]
#[repr(u8)]
pub enum Kind {
Show 17 variants Unknown = 0, Internal = 1, Invalid = 2, Unsupported = 3, NotFound = 4, AlreadyExists = 5, ResourceExhausted = 6, Misuse = 7, Cancelled = 8, Shutdown = 9, Timeout = 10, Conflict = 11, Serialization = 12, Parse = 13, Io = 14, Protocol = 15, Other = 16,
}
Expand description

Category indicates “what went wrong”, in abstract terms.

§Choosing a Kind

  • Kind::Io, Kind::Protocol, and Kind::Other should only be used if there’s no more specific option.

    For example, a network timeout is a type of IO error, however it should use Kind::Timeout rather than Kind::Io.

  • Kind::Invalid should be used when the input will never be valid (at least in this version of the software), rather than input which is invalid because of the current system state.

    For example, an unknown identifier should use Kind::NotFound (for example ockam_vault_core’s Secret) rather than Kind::Invalid,

  • Kind::Cancelled, Kind::Timeout, and Kind::Shutdown all sound similar, but:

    • Kind::Timeout should be used to map operations which timeout externally, such as network requests. These may succeed if retried.

    • Kind::Shutdown should be used to indicate the operation failed due to the node shutting down.

    • Kind::Cancelled is used when a request to cancel the operation comes in while the operation is in progress.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Unknown = 0

Indicates that there is no way to determine a more specific kind.

§

Internal = 1

Used for serious internal errors, including panics.

This generally should not be used unless we’d accept a bug report for the error.

§

Invalid = 2

The input was fundamentally invalid.

For example, this is appropriate to use when:

  • A null pointer being passed as input in the FFI.
  • A string is used as input which is not UTF-8.
  • Parse failures of various kinds, but be sure to include more specific information in the Error payload.

Note that it is not appropriate for input which is invalid only due to the current system state.

§

Unsupported = 3

The requested operation is not supported/implemented by that component.

For example, this is appropriate for a component (for example, a custom Vault) which do not implement the entire API surface.

§

NotFound = 4

Some referenced entity was not found.

For example, this may be appropriate for:

  • A vault which does not recognize a Secret which it receives.
  • FFI that receives an integer handle that does not belong to any known entity.
  • Local Address which don’t correspond to any known Worker or Processor.
  • Address with a transport of an unknown or unsupported type.

Information about what exactly it is that could not be located should be available on the Error itself.

§

AlreadyExists = 5

The operation failed because a resource already exists.

For example, this may be appropriate for:

  • A ockam node already exists
  • A vault state already exists
  • An entry in a cddl file that already has an entry for a given key. This would indicate that a resource has been defined multiple times, possibly in different wasys.

Information about what exactly it is that already existed should be available on the Error itself.

§

ResourceExhausted = 6

Indicates that some resource has been exhausted, or would be exhausted if the request were to be fulfilled.

The resource in question could be memory, open file descriptors, storage, quota, simultaneous in-flight messages or tasks…

Information about which resource it was that was exhausted should be available on the Error itself.

§

Misuse = 7

An API was misused in some unspecific fashion.

This is mostly intended for FFI and other non-Rust bindings — for example, it would be appropriate to map core::cell::BorrowError to this.

§

Cancelled = 8

Indicates the operation failed due to a cancellation request.

See the type documentation on the difference between this, Kind::Shutdown and Kind::Timeout.

§

Shutdown = 9

Indicates that the operation failed due to the node shutting down.

See the type documentation on the difference between this, Kind::Cancelled and Kind::Timeout.

§

Timeout = 10

Indicates that the operation failed due to an external operation timing out, such as a network request, which may succeed if retried.

See the type documentation on the difference between this, Kind::Shutdown and Kind::Cancelled.

§

Conflict = 11

Indicates an operation failed due to simultaneous attempts to modify a resource.

§

Serialization = 12

Indicates an a failure to deserialize a message (or in rare cases, failure to serialize).

§

Parse = 13

Indicates a parsing error.

§

Io = 14

Indicates some other I/O error.

Specifics should be available on error payload.

§

Protocol = 15

Indicates some other I/O error.

Specifics should be available on error payload.

§

Other = 16

Indicates an error that

Specifics should be available on error payload.

Implementations§

source§

impl Kind

source

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

Attempt to construct a Kind from the numeric value.

Trait Implementations§

source§

impl Clone for Kind

source§

fn clone(&self) -> Kind

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Kind

source§

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

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

impl<'de> Deserialize<'de> for Kind

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl From<u8> for Kind

source§

fn from(src: u8) -> Self

Converts to this type from the input type.
source§

impl Hash for Kind

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 Ord for Kind

source§

fn cmp(&self, other: &Kind) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for Kind

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Kind

source§

fn partial_cmp(&self, other: &Kind) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for Kind

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Copy for Kind

source§

impl Eq for Kind

source§

impl StructuralPartialEq for Kind

Auto Trait Implementations§

§

impl Freeze for Kind

§

impl RefUnwindSafe for Kind

§

impl Send for Kind

§

impl Sync for Kind

§

impl Unpin for Kind

§

impl UnwindSafe for Kind

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<D> AsyncTryClone for D
where D: Clone + Sync,

source§

fn async_try_clone<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<D, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, D: 'async_trait,

Try cloning a object and return an Err in case of failure.
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> Decodable for T

source§

fn decode(encoded: &[u8]) -> Result<T, Error>

Decode a slice.
source§

impl<T> Encodable for T
where T: Serialize,

source§

fn encode(self) -> Result<Vec<u8>, Error>

Encode the type into an Encoded type.
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> FutureExt for T

source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

§

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>,

§

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>,

§

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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,