Skip to main content

muse_code_sdk/msp/method/session/
catch_all.rs

1// @generated from the MSP stable schema and protocol sources; do not edit by hand.
2
3use super::{AttentionFlag, SessionKind};
4use serde::{Deserialize, Deserializer, Serialize, Serializer};
5
6impl SessionKind {
7    /// The exact wire spelling, including an unknown word kept verbatim.
8    pub fn as_str(&self) -> &str {
9        match self {
10            Self::Root => "root",
11            Self::Subagent => "subagent",
12            Self::Unknown(word) => word,
13        }
14    }
15}
16
17impl Serialize for SessionKind {
18    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
19        serializer.serialize_str(self.as_str())
20    }
21}
22
23impl<'de> Deserialize<'de> for SessionKind {
24    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
25        let word = String::deserialize(deserializer)?;
26        Ok(match word.as_str() {
27            "root" => Self::Root,
28            "subagent" => Self::Subagent,
29            _ => Self::Unknown(word),
30        })
31    }
32}
33
34impl AttentionFlag {
35    /// The exact wire spelling, including an unknown word kept verbatim.
36    pub fn as_str(&self) -> &str {
37        match self {
38            Self::ApprovalPending => "approvalPending",
39            Self::InputPending => "inputPending",
40            Self::AdmissionPending => "admissionPending",
41            Self::Unknown(word) => word,
42        }
43    }
44}
45
46impl Serialize for AttentionFlag {
47    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
48        serializer.serialize_str(self.as_str())
49    }
50}
51
52impl<'de> Deserialize<'de> for AttentionFlag {
53    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
54        let word = String::deserialize(deserializer)?;
55        Ok(match word.as_str() {
56            "approvalPending" => Self::ApprovalPending,
57            "inputPending" => Self::InputPending,
58            "admissionPending" => Self::AdmissionPending,
59            _ => Self::Unknown(word),
60        })
61    }
62}