Skip to main content

StatusProvider

Trait StatusProvider 

Source
pub trait StatusProvider: From<Self::Inner> + Sized {
    type Inner;
    type WithInner<T>: StatusProvider<Inner = T>;

    const STATUS_CODE: StatusCode;

    // Required method
    fn into_inner(self) -> Self::Inner;

    // Provided methods
    fn into_set<E>(self) -> ApiResponse<E>
       where Self::Inner: IntoResponse,
             E: Contains<Self> { ... }
    fn map<T>(self, f: impl FnOnce(Self::Inner) -> T) -> Self::WithInner<T> { ... }
}
Expand description

A StatusCode that wraps an inner value, and can thus be used for easy error propagation while keeping track of the status-code in the type-system.

This trait is implemented for all codes in the codes module.

Required Associated Constants§

Source

const STATUS_CODE: StatusCode

The status code associated with type.

Required Associated Types§

Source

type Inner

The inner value type that is wrapped by this status wrapper.

Source

type WithInner<T>: StatusProvider<Inner = T>

Required Methods§

Source

fn into_inner(self) -> Self::Inner

Convert this status wrapper into its inner value.

Provided Methods§

Source

fn into_set<E>(self) -> ApiResponse<E>
where Self::Inner: IntoResponse, E: Contains<Self>,

Convert this status wrapper into an [ApiErrorSet] with the given inner value type. (into can be used as well)

Source

fn map<T>(self, f: impl FnOnce(Self::Inner) -> T) -> Self::WithInner<T>

Apply a function to the inner value of this status wrapper, producing a new wrapper with the transformed inner value.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<T> StatusProvider for BadGateway<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::BAD_GATEWAY

Source§

type Inner = T

Source§

type WithInner<R> = BadGateway<R>

Source§

impl<T> StatusProvider for BadRequest<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::BAD_REQUEST

Source§

type Inner = T

Source§

type WithInner<R> = BadRequest<R>

Source§

impl<T> StatusProvider for Conflict<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::CONFLICT

Source§

type Inner = T

Source§

type WithInner<R> = Conflict<R>

Source§

impl<T> StatusProvider for ExpectationFailed<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::EXPECTATION_FAILED

Source§

type Inner = T

Source§

type WithInner<R> = ExpectationFailed<R>

Source§

impl<T> StatusProvider for FailedDependency<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::FAILED_DEPENDENCY

Source§

type Inner = T

Source§

type WithInner<R> = FailedDependency<R>

Source§

impl<T> StatusProvider for Forbidden<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::FORBIDDEN

Source§

type Inner = T

Source§

type WithInner<R> = Forbidden<R>

Source§

impl<T> StatusProvider for GatewayTimeout<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::GATEWAY_TIMEOUT

Source§

type Inner = T

Source§

type WithInner<R> = GatewayTimeout<R>

Source§

impl<T> StatusProvider for Gone<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::GONE

Source§

type Inner = T

Source§

type WithInner<R> = Gone<R>

Source§

impl<T> StatusProvider for HttpVersionNotSupported<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::HTTP_VERSION_NOT_SUPPORTED

Source§

type Inner = T

Source§

type WithInner<R> = HttpVersionNotSupported<R>

Source§

impl<T> StatusProvider for ImATeapot<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::IM_A_TEAPOT

Source§

type Inner = T

Source§

type WithInner<R> = ImATeapot<R>

Source§

impl<T> StatusProvider for InsufficientStorage<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::INSUFFICIENT_STORAGE

Source§

type Inner = T

Source§

type WithInner<R> = InsufficientStorage<R>

Source§

impl<T> StatusProvider for Internal<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::INTERNAL_SERVER_ERROR

Source§

type Inner = T

Source§

type WithInner<R> = Internal<R>

Source§

impl<T> StatusProvider for LengthRequired<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::LENGTH_REQUIRED

Source§

type Inner = T

Source§

type WithInner<R> = LengthRequired<R>

Source§

impl<T> StatusProvider for Locked<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::LOCKED

Source§

type Inner = T

Source§

type WithInner<R> = Locked<R>

Source§

impl<T> StatusProvider for LoopDetected<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::LOOP_DETECTED

Source§

type Inner = T

Source§

type WithInner<R> = LoopDetected<R>

Source§

impl<T> StatusProvider for MethodNotAllowed<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::METHOD_NOT_ALLOWED

Source§

type Inner = T

Source§

type WithInner<R> = MethodNotAllowed<R>

Source§

impl<T> StatusProvider for MisdirectedRequest<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::MISDIRECTED_REQUEST

Source§

type Inner = T

Source§

type WithInner<R> = MisdirectedRequest<R>

Source§

impl<T> StatusProvider for NetworkAuthenticationRequired<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::NETWORK_AUTHENTICATION_REQUIRED

Source§

type Inner = T

Source§

type WithInner<R> = NetworkAuthenticationRequired<R>

Source§

impl<T> StatusProvider for NotAcceptable<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::NOT_ACCEPTABLE

Source§

type Inner = T

Source§

type WithInner<R> = NotAcceptable<R>

Source§

impl<T> StatusProvider for NotExtended<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::NOT_EXTENDED

Source§

type Inner = T

Source§

type WithInner<R> = NotExtended<R>

Source§

impl<T> StatusProvider for NotFound<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::NOT_FOUND

Source§

type Inner = T

Source§

type WithInner<R> = NotFound<R>

Source§

impl<T> StatusProvider for NotImplemented<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::NOT_IMPLEMENTED

Source§

type Inner = T

Source§

type WithInner<R> = NotImplemented<R>

Source§

impl<T> StatusProvider for PayloadTooLarge<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::PAYLOAD_TOO_LARGE

Source§

type Inner = T

Source§

type WithInner<R> = PayloadTooLarge<R>

Source§

impl<T> StatusProvider for PaymentRequired<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::PAYMENT_REQUIRED

Source§

type Inner = T

Source§

type WithInner<R> = PaymentRequired<R>

Source§

impl<T> StatusProvider for PreconditionFailed<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::PRECONDITION_FAILED

Source§

type Inner = T

Source§

type WithInner<R> = PreconditionFailed<R>

Source§

impl<T> StatusProvider for PreconditionRequired<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::PRECONDITION_REQUIRED

Source§

type Inner = T

Source§

type WithInner<R> = PreconditionRequired<R>

Source§

impl<T> StatusProvider for ProxyAuthenticationRequired<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::PROXY_AUTHENTICATION_REQUIRED

Source§

type Inner = T

Source§

type WithInner<R> = ProxyAuthenticationRequired<R>

Source§

impl<T> StatusProvider for RangeNotSatisfiable<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::RANGE_NOT_SATISFIABLE

Source§

type Inner = T

Source§

type WithInner<R> = RangeNotSatisfiable<R>

Source§

impl<T> StatusProvider for RequestHeaderFieldsTooLarge<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::REQUEST_HEADER_FIELDS_TOO_LARGE

Source§

type Inner = T

Source§

type WithInner<R> = RequestHeaderFieldsTooLarge<R>

Source§

impl<T> StatusProvider for RequestTimeout<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::REQUEST_TIMEOUT

Source§

type Inner = T

Source§

type WithInner<R> = RequestTimeout<R>

Source§

impl<T> StatusProvider for ServiceUnavailable<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::SERVICE_UNAVAILABLE

Source§

type Inner = T

Source§

type WithInner<R> = ServiceUnavailable<R>

Source§

impl<T> StatusProvider for TooEarly<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::TOO_EARLY

Source§

type Inner = T

Source§

type WithInner<R> = TooEarly<R>

Source§

impl<T> StatusProvider for TooManyRequests<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::TOO_MANY_REQUESTS

Source§

type Inner = T

Source§

type WithInner<R> = TooManyRequests<R>

Source§

impl<T> StatusProvider for Unauthorized<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::UNAUTHORIZED

Source§

type Inner = T

Source§

type WithInner<R> = Unauthorized<R>

Source§

impl<T> StatusProvider for UnavailableForLegalReasons<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::UNAVAILABLE_FOR_LEGAL_REASONS

Source§

type Inner = T

Source§

type WithInner<R> = UnavailableForLegalReasons<R>

Source§

impl<T> StatusProvider for UnprocessableEntity<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::UNPROCESSABLE_ENTITY

Source§

type Inner = T

Source§

type WithInner<R> = UnprocessableEntity<R>

Source§

impl<T> StatusProvider for UnsupportedMediaType<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::UNSUPPORTED_MEDIA_TYPE

Source§

type Inner = T

Source§

type WithInner<R> = UnsupportedMediaType<R>

Source§

impl<T> StatusProvider for UpgradeRequired<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::UPGRADE_REQUIRED

Source§

type Inner = T

Source§

type WithInner<R> = UpgradeRequired<R>

Source§

impl<T> StatusProvider for UriTooLong<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::URI_TOO_LONG

Source§

type Inner = T

Source§

type WithInner<R> = UriTooLong<R>

Source§

impl<T> StatusProvider for VariantAlsoNegotiates<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::VARIANT_ALSO_NEGOTIATES

Source§

type Inner = T

Source§

type WithInner<R> = VariantAlsoNegotiates<R>