Skip to main content

muse_code_sdk/msp/view/user_input/
catch_all.rs

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