Skip to main content

muse_code_sdk/msp/view/item_background/
catch_all.rs

1// @generated from the MSP stable schema and protocol sources; do not edit by hand.
2
3use super::{BackgroundInitiator, BackgroundState};
4use serde::{Deserialize, Deserializer, Serialize, Serializer};
5
6impl BackgroundInitiator {
7    /// The exact wire spelling, including an unknown word kept verbatim.
8    pub fn as_str(&self) -> &str {
9        match self {
10            Self::User => "user",
11            Self::Timeout => "timeout",
12            Self::Unknown(word) => word,
13        }
14    }
15}
16
17impl Serialize for BackgroundInitiator {
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 BackgroundInitiator {
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            "user" => Self::User,
28            "timeout" => Self::Timeout,
29            _ => Self::Unknown(word),
30        })
31    }
32}
33
34impl BackgroundState {
35    /// The exact wire spelling, including an unknown word kept verbatim.
36    pub fn as_str(&self) -> &str {
37        match self {
38            Self::Backgrounded => "backgrounded",
39            Self::Unknown(word) => word,
40        }
41    }
42}
43
44impl Serialize for BackgroundState {
45    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
46        serializer.serialize_str(self.as_str())
47    }
48}
49
50impl<'de> Deserialize<'de> for BackgroundState {
51    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
52        let word = String::deserialize(deserializer)?;
53        Ok(match word.as_str() {
54            "backgrounded" => Self::Backgrounded,
55            _ => Self::Unknown(word),
56        })
57    }
58}