Skip to main content

muse_code_sdk/msp/method/lifecycle/
session_resume_wire_words.rs

1// @generated from the MSP stable schema and protocol sources; do not edit by hand.
2
3use super::session_resume::HistoryMode;
4use super::session_resume::HistoryNoneReason;
5use serde::Deserialize;
6use serde::Deserializer;
7use serde::Serialize;
8use serde::Serializer;
9
10impl HistoryMode {
11    /// The exact wire spelling, including a value from a newer host.
12    #[must_use]
13    pub fn as_str(&self) -> &str {
14        match self {
15            Self::AnchoredSnapshot => "anchoredSnapshot",
16            Self::Inline => "inline",
17            Self::Snapshot => "snapshot",
18            Self::None => "none",
19            Self::Unknown(value) => value,
20        }
21    }
22}
23
24impl Serialize for HistoryMode {
25    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
26    where
27        S: Serializer,
28    {
29        serializer.serialize_str(self.as_str())
30    }
31}
32
33impl<'de> Deserialize<'de> for HistoryMode {
34    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
35    where
36        D: Deserializer<'de>,
37    {
38        let value = String::deserialize(deserializer)?;
39        Ok(match value.as_str() {
40            "anchoredSnapshot" => Self::AnchoredSnapshot,
41            "inline" => Self::Inline,
42            "snapshot" => Self::Snapshot,
43            "none" => Self::None,
44            _ => Self::Unknown(value),
45        })
46    }
47}
48
49impl HistoryNoneReason {
50    /// The exact wire spelling, including a value from a newer host.
51    #[must_use]
52    pub fn as_str(&self) -> &str {
53        match self {
54            Self::Excluded => "excluded",
55            Self::CursorSuffix => "cursorSuffix",
56            Self::HistoryBudget => "historyBudget",
57            Self::ProjectionUnavailable => "projectionUnavailable",
58            Self::ProjectionReadLimit => "projectionReadLimit",
59            Self::Unknown(value) => value,
60        }
61    }
62}
63
64impl Serialize for HistoryNoneReason {
65    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
66    where
67        S: Serializer,
68    {
69        serializer.serialize_str(self.as_str())
70    }
71}
72
73impl<'de> Deserialize<'de> for HistoryNoneReason {
74    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
75    where
76        D: Deserializer<'de>,
77    {
78        let value = String::deserialize(deserializer)?;
79        Ok(match value.as_str() {
80            "excluded" => Self::Excluded,
81            "cursorSuffix" => Self::CursorSuffix,
82            "historyBudget" => Self::HistoryBudget,
83            "projectionUnavailable" => Self::ProjectionUnavailable,
84            "projectionReadLimit" => Self::ProjectionReadLimit,
85            _ => Self::Unknown(value),
86        })
87    }
88}