pub trait Status<T, E>: Sealed {
// Required methods
fn status<S>(self, status: S) -> Result<T, Error>
where S: TryInto<StatusCode>,
S::Error: Debug;
fn with_status<S, F>(self, f: F) -> Result<T, Error>
where S: TryInto<StatusCode>,
S::Error: Debug,
F: FnOnce() -> S;
}
Expand description
Provides the status
method for Result
and Option
.
This trait is sealed and cannot be implemented outside of http-types
.
Required Methods§
Sourcefn status<S>(self, status: S) -> Result<T, Error>
fn status<S>(self, status: S) -> Result<T, Error>
Wrap the error value with an additional status code.
Sourcefn with_status<S, F>(self, f: F) -> Result<T, Error>
fn with_status<S, F>(self, f: F) -> Result<T, Error>
Wrap the error value with an additional status code that is evaluated lazily only once an error does occur.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<T> Status<T, Infallible> for Option<T>
impl<T> Status<T, Infallible> for Option<T>
Source§fn status<S>(self, status: S) -> Result<T, Error>
fn status<S>(self, status: S) -> Result<T, Error>
Wrap the error value with an additional status code.
§Panics
Panics if Status
is not a valid StatusCode
.
Source§fn with_status<S, F>(self, f: F) -> Result<T, Error>
fn with_status<S, F>(self, f: F) -> Result<T, Error>
Wrap the error value with an additional status code that is evaluated lazily only once an error does occur.
§Panics
Panics if Status
is not a valid StatusCode
.
Source§impl<T, E> Status<T, E> for Result<T, E>
impl<T, E> Status<T, E> for Result<T, E>
Source§fn status<S>(self, status: S) -> Result<T, Error>
fn status<S>(self, status: S) -> Result<T, Error>
Wrap the error value with an additional status code.
§Panics
Panics if Status
is not a valid StatusCode
.
Source§fn with_status<S, F>(self, f: F) -> Result<T, Error>
fn with_status<S, F>(self, f: F) -> Result<T, Error>
Wrap the error value with an additional status code that is evaluated lazily only once an error does occur.
§Panics
Panics if Status
is not a valid StatusCode
.