Skip to main content

muse_code_sdk/msp/method/computer_use/
catch_all.rs

1// @generated from the MSP stable schema and protocol sources; do not edit by hand.
2
3use super::ComputerUseChoice;
4use serde::{Deserialize, Deserializer, Serialize, Serializer};
5
6impl ComputerUseChoice {
7    /// The exact wire spelling, including an unknown word kept verbatim.
8    pub fn as_str(&self) -> &str {
9        match self {
10            Self::Ask => "ask",
11            Self::AlwaysAllow => "alwaysAllow",
12            Self::Unknown(word) => word,
13        }
14    }
15}
16
17impl Serialize for ComputerUseChoice {
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 ComputerUseChoice {
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            "ask" => Self::Ask,
28            "alwaysAllow" => Self::AlwaysAllow,
29            _ => Self::Unknown(word),
30        })
31    }
32}