pub enum HealthStatus {
Pass,
Fail,
Warn,
}Expand description
RFC 8458 §3 health check status.
Serializes as lowercase "pass", "fail", or "warn".
§Examples
use api_bones::health::HealthStatus;
let pass = HealthStatus::Pass;
let fail = HealthStatus::Fail;
let warn = HealthStatus::Warn;
assert_eq!(pass.http_status(), 200);
assert_eq!(fail.http_status(), 503);
assert_eq!(warn.http_status(), 200);Variants§
Pass
The service is healthy and all checks pass.
Fail
The service is unhealthy; callers should not route traffic here.
Warn
The service is degraded but still operational.
Implementations§
Source§impl HealthStatus
impl HealthStatus
Sourcepub const fn http_status(&self) -> u16
pub const fn http_status(&self) -> u16
HTTP status code for a response carrying this health status.
Pass/Warn→200 OKFail→503 Service Unavailable
§Examples
use api_bones::health::HealthStatus;
assert_eq!(HealthStatus::Pass.http_status(), 200);
assert_eq!(HealthStatus::Warn.http_status(), 200);
assert_eq!(HealthStatus::Fail.http_status(), 503);Sourcepub const fn is_available(&self) -> bool
pub const fn is_available(&self) -> bool
Returns true if the status indicates healthy or degraded-but-operational.
§Examples
use api_bones::health::HealthStatus;
assert!(HealthStatus::Pass.is_available());
assert!(HealthStatus::Warn.is_available());
assert!(!HealthStatus::Fail.is_available());Trait Implementations§
Source§impl Clone for HealthStatus
impl Clone for HealthStatus
Source§fn clone(&self) -> HealthStatus
fn clone(&self) -> HealthStatus
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for HealthStatus
impl Debug for HealthStatus
Source§impl<'de> Deserialize<'de> for HealthStatus
impl<'de> Deserialize<'de> for HealthStatus
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for HealthStatus
impl Display for HealthStatus
Source§impl PartialEq for HealthStatus
impl PartialEq for HealthStatus
Source§impl Serialize for HealthStatus
impl Serialize for HealthStatus
impl Eq for HealthStatus
impl StructuralPartialEq for HealthStatus
Auto Trait Implementations§
impl Freeze for HealthStatus
impl RefUnwindSafe for HealthStatus
impl Send for HealthStatus
impl Sync for HealthStatus
impl Unpin for HealthStatus
impl UnsafeUnpin for HealthStatus
impl UnwindSafe for HealthStatus
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ValidateIp for Twhere
T: ToString,
impl<T> ValidateIp for Twhere
T: ToString,
Source§fn validate_ipv4(&self) -> bool
fn validate_ipv4(&self) -> bool
Validates whether the given string is an IP V4
Source§fn validate_ipv6(&self) -> bool
fn validate_ipv6(&self) -> bool
Validates whether the given string is an IP V6
Source§fn validate_ip(&self) -> bool
fn validate_ip(&self) -> bool
Validates whether the given string is an IP