pub struct HealthCheck {
pub component_type: String,
pub status: HealthStatus,
pub output: Option<String>,
pub time: Option<String>,
}Expand description
Individual component check result (RFC 8458 §4).
Used as values in ReadinessResponse::checks.
Map key format: "<component>:<measurement>", e.g. "postgres:connection".
Requires std or alloc (fields contain String).
Fields§
§component_type: StringComponent type, e.g. "datastore", "component", "system".
status: HealthStatusCheck result status.
output: Option<String>Human-readable output or error message. Omitted when absent.
time: Option<String>RFC 3339 timestamp of when this check was last performed. Omitted when absent.
Implementations§
Source§impl HealthCheck
impl HealthCheck
Sourcepub fn pass(component_type: impl Into<String>) -> Self
pub fn pass(component_type: impl Into<String>) -> Self
Create a passing component check.
§Examples
use api_bones::health::{HealthCheck, HealthStatus};
let check = HealthCheck::pass("datastore");
assert_eq!(check.status, HealthStatus::Pass);
assert_eq!(check.component_type, "datastore");
assert!(check.output.is_none());Sourcepub fn fail(
component_type: impl Into<String>,
output: impl Into<String>,
) -> Self
pub fn fail( component_type: impl Into<String>, output: impl Into<String>, ) -> Self
Create a failing component check with an error message.
§Examples
use api_bones::health::{HealthCheck, HealthStatus};
let check = HealthCheck::fail("datastore", "connection timeout");
assert_eq!(check.status, HealthStatus::Fail);
assert_eq!(check.output.as_deref(), Some("connection timeout"));Sourcepub fn warn(
component_type: impl Into<String>,
output: impl Into<String>,
) -> Self
pub fn warn( component_type: impl Into<String>, output: impl Into<String>, ) -> Self
Create a warn-level component check with a message.
§Examples
use api_bones::health::{HealthCheck, HealthStatus};
let check = HealthCheck::warn("datastore", "high latency");
assert_eq!(check.status, HealthStatus::Warn);
assert_eq!(check.output.as_deref(), Some("high latency"));Sourcepub fn with_time(self, time: impl Into<String>) -> Self
pub fn with_time(self, time: impl Into<String>) -> Self
Attach an RFC 3339 timestamp to this check result.
§Examples
use api_bones::health::HealthCheck;
let check = HealthCheck::pass("datastore")
.with_time("2026-01-01T00:00:00Z");
assert_eq!(check.time.as_deref(), Some("2026-01-01T00:00:00Z"));Sourcepub fn builder() -> HealthCheckBuilder<(), ()>
pub fn builder() -> HealthCheckBuilder<(), ()>
Return a typed builder for constructing a HealthCheck.
Required fields (component_type and status) must be set before calling
HealthCheckBuilder::build; the compiler enforces this via typestate.
§Example
use api_bones::health::{HealthCheck, HealthStatus};
let check = HealthCheck::builder()
.component_type("datastore")
.status(HealthStatus::Pass)
.build();
assert_eq!(check.status, HealthStatus::Pass);Trait Implementations§
Source§impl Clone for HealthCheck
impl Clone for HealthCheck
Source§fn clone(&self) -> HealthCheck
fn clone(&self) -> HealthCheck
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more