Skip to main content

muse_code_sdk/msp/view/
health_wire_words.rs

1// @generated from the MSP stable schema and protocol sources; do not edit by hand.
2
3use super::health::SessionViewHealth;
4use serde::Deserialize;
5use serde::Deserializer;
6use serde::Serialize;
7use serde::Serializer;
8
9impl SessionViewHealth {
10    /// The exact wire spelling, including a value from a newer host.
11    #[must_use]
12    pub fn as_str(&self) -> &str {
13        match self {
14            Self::Unavailable => "unavailable",
15            Self::Healthy => "healthy",
16            Self::Unknown(value) => value,
17        }
18    }
19}
20
21impl Serialize for SessionViewHealth {
22    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
23    where
24        S: Serializer,
25    {
26        serializer.serialize_str(self.as_str())
27    }
28}
29
30impl<'de> Deserialize<'de> for SessionViewHealth {
31    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
32    where
33        D: Deserializer<'de>,
34    {
35        let value = String::deserialize(deserializer)?;
36        Ok(match value.as_str() {
37            "unavailable" => Self::Unavailable,
38            "healthy" => Self::Healthy,
39            _ => Self::Unknown(value),
40        })
41    }
42}