summaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
authorToby Vincent <tobyv@tobyvin.dev>2024-09-27 12:16:23 -0500
committerToby Vincent <tobyv@tobyvin.dev>2024-09-27 12:16:23 -0500
commit1218705fd52771a902eb6c64762623d0c6a13173 (patch)
treeafdded96bff04b8e22704e54dedff5bf78e28229 /src/lib.rs
parentfd992d7e3c03f37fbcafe9d3f26c72a2ead3b2a7 (diff)
refactor: merge Check into Status type
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 2c9fa91..1ccecf7 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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()
}