Skip to main content

StatusResultExt

Trait StatusResultExt 

Source
pub trait StatusResultExt {
    type Ok;
    type Err;

    // Required methods
    fn into_bad_request(self) -> Result<Self::Ok, BadRequest<Self::Err>>;
    fn into_unauthorized(self) -> Result<Self::Ok, Unauthorized<Self::Err>>;
    fn into_forbidden(self) -> Result<Self::Ok, Forbidden<Self::Err>>;
    fn into_not_found(self) -> Result<Self::Ok, NotFound<Self::Err>>;
    fn into_conflict(self) -> Result<Self::Ok, Conflict<Self::Err>>;
    fn into_unprocessable_entity(
        self,
    ) -> Result<Self::Ok, UnprocessableEntity<Self::Err>>;
    fn into_too_many_requests(
        self,
    ) -> Result<Self::Ok, TooManyRequests<Self::Err>>;
    fn into_internal(self) -> Result<Self::Ok, InternalServerError<Self::Err>>;
    fn into_bad_gateway(self) -> Result<Self::Ok, BadGateway<Self::Err>>;
    fn into_service_unavailable(
        self,
    ) -> Result<Self::Ok, ServiceUnavailable<Self::Err>>;
    fn into_gateway_timeout(self) -> Result<Self::Ok, GatewayTimeout<Self::Err>>;
}
Expand description

Extension trait for Result to convert it into a Result with an [ApiError].

Required Associated Types§

Source

type Ok

The Ok type of the Result.

Source

type Err

The Err type of the Result.

Required Methods§

Source

fn into_bad_request(self) -> Result<Self::Ok, BadRequest<Self::Err>>

Converts the error into a 400 Bad Request API error.

Source

fn into_unauthorized(self) -> Result<Self::Ok, Unauthorized<Self::Err>>

Converts the error into a 401 Unauthorized API error.

Source

fn into_forbidden(self) -> Result<Self::Ok, Forbidden<Self::Err>>

Converts the error into a 403 Forbidden API error.

Source

fn into_not_found(self) -> Result<Self::Ok, NotFound<Self::Err>>

Converts the error into a 404 Not Found API error.

Source

fn into_conflict(self) -> Result<Self::Ok, Conflict<Self::Err>>

Converts the error into a 409 Conflict API error.

Source

fn into_unprocessable_entity( self, ) -> Result<Self::Ok, UnprocessableEntity<Self::Err>>

Converts the error into a 422 Unprocessable Entity API error.

Source

fn into_too_many_requests(self) -> Result<Self::Ok, TooManyRequests<Self::Err>>

Converts the error into a 429 Too Many Requests API error.

Source

fn into_internal(self) -> Result<Self::Ok, InternalServerError<Self::Err>>

Converts the error into a 500 Internal Server Error API error.

Source

fn into_bad_gateway(self) -> Result<Self::Ok, BadGateway<Self::Err>>

Converts the error into a 502 Bad Gateway API error.

Source

fn into_service_unavailable( self, ) -> Result<Self::Ok, ServiceUnavailable<Self::Err>>

Converts the error into a 503 Service Unavailable API error.

Source

fn into_gateway_timeout(self) -> Result<Self::Ok, GatewayTimeout<Self::Err>>

Converts the error into a 504 Gateway Timeout API error.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<T, E> StatusResultExt for Result<T, E>

Implementors§