pub struct HttpStatusHelper<'a, T>(pub &'a T);Expand description
Helper wrapper used by generated HTTP handler code to map error values to HTTP status codes.
Method resolution picks the inherent impl (using IntoErrorCode) when the
wrapped type implements IntoErrorCode, and falls back to the
HttpStatusFallback trait impl (which returns 500) otherwise.
§Example (generated code pattern)
ⓘ
use ::server_less::HttpStatusFallback as _;
let status_u16 = ::server_less::HttpStatusHelper(&err).http_status_code();Tuple Fields§
§0: &'a TImplementations§
Source§impl<T> HttpStatusHelper<'_, T>where
T: IntoErrorCode,
impl<T> HttpStatusHelper<'_, T>where
T: IntoErrorCode,
Sourcepub fn http_status_code(&self) -> u16
pub fn http_status_code(&self) -> u16
Returns the HTTP status code derived from IntoErrorCode::error_code.
Trait Implementations§
Source§impl<T> HttpStatusFallback for HttpStatusHelper<'_, T>
impl<T> HttpStatusFallback for HttpStatusHelper<'_, T>
Source§fn http_status_code(&self) -> u16
fn http_status_code(&self) -> u16
Fallback: returns 500 Internal Server Error for types that do not
implement IntoErrorCode.
Auto Trait Implementations§
impl<'a, T> Freeze for HttpStatusHelper<'a, T>
impl<'a, T> RefUnwindSafe for HttpStatusHelper<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Send for HttpStatusHelper<'a, T>where
T: Sync,
impl<'a, T> Sync for HttpStatusHelper<'a, T>where
T: Sync,
impl<'a, T> Unpin for HttpStatusHelper<'a, T>
impl<'a, T> UnsafeUnpin for HttpStatusHelper<'a, T>
impl<'a, T> UnwindSafe for HttpStatusHelper<'a, T>where
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more