Skip to main content

HttpErrorAlg

Trait HttpErrorAlg 

Source
pub trait HttpErrorAlg {
    const HTTP_STATUSES: &'static [HttpStatus];

    // Required methods
    fn http_status(&self) -> HttpStatus;
    fn http_message(&self) -> String;
}
Expand description

States what one failure means to a caller.

A handler that can fail returns a Result, and its endpoint answers with what the failure means rather than with the failure itself. That meaning is HTTP vocabulary rather than domain vocabulary, which is why a domain states its failures and this states how they are answered.

Required Associated Constants§

Source

const HTTP_STATUSES: &'static [HttpStatus]

Every status this failure can be answered with.

An interpretation that runs asks a failure what it means and is given one status. An interpretation that only reads a program has no failure to ask, so what an endpoint can answer with has to be stated by the type rather than by a value.

Required Methods§

Source

fn http_status(&self) -> HttpStatus

Returns the status this failure is answered with.

Source

fn http_message(&self) -> String

Returns the message this failure is answered with.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl HttpErrorAlg for Error

Source§

impl HttpErrorAlg for Infallible

Implementors§