Skip to main content

RejectionCode

Trait RejectionCode 

Source
pub trait RejectionCode:
    Copy
    + Eq
    + Hash
    + Debug
    + Display
    + Into<&'static str>
    + Send
    + Sync
    + 'static {
    const CODES: &'static [CodeInfo];
}
Expand description

The code type of a rejection family: a closed, enumerable catalogue.

use errlanes::RejectionCode;

/// The thing is missing.
#[derive(errlanes::Rejection, Debug)]
#[rejection(code = "NOT_FOUND")]
#[error("the thing is missing")]
struct NotFound;

for entry in <NotFoundCode as RejectionCode>::CODES {
    assert_eq!(entry.code, "NOT_FOUND");
    assert_eq!(entry.description, Some("The thing is missing."));
}

Required Associated Constants§

Source

const CODES: &'static [CodeInfo]

Every code a value of this type can resolve to — complete through delegate, code_and_level_from, and #[lift(..)]-forwarded variants; no duplicates (a diamond keeps its first occurrence); declaration order, depth-first.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§