Skip to main content

muse_code_sdk/msp/view/state/usage/
catch_all.rs

1// @generated from the MSP stable schema and protocol sources; do not edit by hand.
2
3use super::ContextPressureLevel;
4use serde::{Deserialize, Deserializer, Serialize, Serializer};
5
6impl ContextPressureLevel {
7    /// The exact wire spelling, including an unknown word kept verbatim.
8    pub fn as_str(&self) -> &str {
9        match self {
10            Self::Normal => "normal",
11            Self::Warning => "warning",
12            Self::Blocked => "blocked",
13            Self::Unknown(word) => word,
14        }
15    }
16}
17
18impl Serialize for ContextPressureLevel {
19    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20        serializer.serialize_str(self.as_str())
21    }
22}
23
24impl<'de> Deserialize<'de> for ContextPressureLevel {
25    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
26        let word = String::deserialize(deserializer)?;
27        Ok(match word.as_str() {
28            "normal" => Self::Normal,
29            "warning" => Self::Warning,
30            "blocked" => Self::Blocked,
31            _ => Self::Unknown(word),
32        })
33    }
34}