diff options
author | Toby Vincent <tobyv@tobyvin.dev> | 2024-09-27 12:16:23 -0500 |
---|---|---|
committer | Toby Vincent <tobyv@tobyvin.dev> | 2024-09-27 12:16:23 -0500 |
commit | 1218705fd52771a902eb6c64762623d0c6a13173 (patch) | |
tree | afdded96bff04b8e22704e54dedff5bf78e28229 /src/lib.rs | |
parent | fd992d7e3c03f37fbcafe9d3f26c72a2ead3b2a7 (diff) |
refactor: merge Check into Status type
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -11,21 +11,21 @@ pub mod error; pub mod service; #[derive(Debug, Clone, Default, Serialize, Deserialize)] -#[serde(rename_all = "lowercase")] +#[serde(rename_all = "lowercase", tag = "status", content = "output")] pub enum Status { #[default] Pass, - Fail, - Warn, + Fail(Option<String>), + Warn(Option<String>), } -#[derive(Debug, Clone, Default, Serialize, Deserialize)] -pub struct Check { - pub status: Status, - pub output: Option<String>, +impl<T: std::error::Error> From<T> for Status { + fn from(value: T) -> Self { + Status::Fail(Some(value.to_string())) + } } -impl axum::response::IntoResponse for Check { +impl axum::response::IntoResponse for Status { fn into_response(self) -> axum::response::Response { axum::Json(self).into_response() } |