use super::*;
macro_rules! define_codes {
(
$(
$(#[$meta:meta])*
code $name:ident => $status:expr;
)*
) => {
$(
$(#[$meta])*
#[derive(Debug, Clone, Copy)]
pub struct $name<T = ()>(pub T);
impl<T, R, S> From<$name<R>> for ErrorSet<S, T>
where
R: Into<S>,
T: Contains<$name>,
{
fn from(err: $name<R>) -> Self {
ErrorSet::new(err)
}
}
impl<T> StatusWrapper for $name<T> {
const STATUS_CODE: StatusCode = $status;
type Inner = T;
type Pure = $name;
fn into_inner(self) -> Self::Inner {
self.0
}
}
)*
};
}
define_codes!(
code BadRequest => StatusCode::BAD_REQUEST;
code Unauthorized => StatusCode::UNAUTHORIZED;
code PaymentRequired => StatusCode::PAYMENT_REQUIRED;
code Forbidden => StatusCode::FORBIDDEN;
code NotFound => StatusCode::NOT_FOUND;
code MethodNotAllowed => StatusCode::METHOD_NOT_ALLOWED;
code NotAcceptable => StatusCode::NOT_ACCEPTABLE;
code ProxyAuthenticationRequired => StatusCode::PROXY_AUTHENTICATION_REQUIRED;
code RequestTimeout => StatusCode::REQUEST_TIMEOUT;
code Conflict => StatusCode::CONFLICT;
code Gone => StatusCode::GONE;
code LengthRequired => StatusCode::LENGTH_REQUIRED;
code PreconditionFailed => StatusCode::PRECONDITION_FAILED;
code UriTooLong => StatusCode::URI_TOO_LONG;
code UnsupportedMediaType => StatusCode::UNSUPPORTED_MEDIA_TYPE;
code RangeNotSatisfiable => StatusCode::RANGE_NOT_SATISFIABLE;
code ExpectationFailed => StatusCode::EXPECTATION_FAILED;
code ImATeapot => StatusCode::IM_A_TEAPOT;
code MisdirectedRequest => StatusCode::MISDIRECTED_REQUEST;
code UnprocessableEntity => StatusCode::UNPROCESSABLE_ENTITY;
code Locked => StatusCode::LOCKED;
code FailedDependency => StatusCode::FAILED_DEPENDENCY;
code UpgradeRequired => StatusCode::UPGRADE_REQUIRED;
code PreconditionRequired => StatusCode::PRECONDITION_REQUIRED;
code TooManyRequests => StatusCode::TOO_MANY_REQUESTS;
code RequestHeaderFieldsTooLarge => StatusCode::REQUEST_HEADER_FIELDS_TOO_LARGE;
code UnavailableForLegalReasons => StatusCode::UNAVAILABLE_FOR_LEGAL_REASONS;
code InternalServerError => StatusCode::INTERNAL_SERVER_ERROR;
code NotImplemented => StatusCode::NOT_IMPLEMENTED;
code BadGateway => StatusCode::BAD_GATEWAY;
code ServiceUnavailable => StatusCode::SERVICE_UNAVAILABLE;
code GatewayTimeout => StatusCode::GATEWAY_TIMEOUT;
code HttpVersionNotSupported => StatusCode::HTTP_VERSION_NOT_SUPPORTED;
code VariantAlsoNegotiates => StatusCode::VARIANT_ALSO_NEGOTIATES;
code InsufficientStorage => StatusCode::INSUFFICIENT_STORAGE;
code LoopDetected => StatusCode::LOOP_DETECTED;
code NotExtended => StatusCode::NOT_EXTENDED;
code NetworkAuthenticationRequired => StatusCode::NETWORK_AUTHENTICATION_REQUIRED;
);