plexus_core/activations/health/
methods.rs1use schemars::JsonSchema;
6use serde::{Deserialize, Serialize};
7
8#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
10#[serde(tag = "method", content = "params", rename_all = "snake_case")]
11pub enum HealthMethod {
12 Check,
14}
15
16impl HealthMethod {
17 pub fn name(&self) -> &'static str {
19 match self {
20 HealthMethod::Check => "check",
21 }
22 }
23
24 pub fn all_names() -> Vec<&'static str> {
26 vec!["check"]
27 }
28
29 pub fn schema() -> serde_json::Value {
31 let schema = schemars::schema_for!(HealthMethod);
32 serde_json::to_value(schema).unwrap()
33 }
34
35 pub fn description(method_name: &str) -> Option<&'static str> {
37 match method_name {
38 "check" => Some("Check the health status of the hub and return uptime"),
39 _ => None,
40 }
41 }
42}
43
44impl crate::plexus::MethodEnumSchema for HealthMethod {
45 fn method_names() -> &'static [&'static str] {
46 &["check"]
47 }
48
49 fn schema_with_consts() -> serde_json::Value {
50 serde_json::to_value(schemars::schema_for!(HealthMethod)).expect("Schema should serialize")
52 }
53}
54
55#[cfg(test)]
56mod tests {
57 use super::*;
58
59 #[test]
60 fn test_method_names() {
61 let method = HealthMethod::Check;
62 assert_eq!(method.name(), "check");
63 }
64
65 #[test]
66 fn test_schema_generation() {
67 let schema = HealthMethod::schema();
68 let schema_str = serde_json::to_string(&schema).unwrap();
69 assert!(schema_str.contains("check"));
71 }
72}