Skip to main content

muse_code_sdk/msp/view/
item_hold.rs

1// @generated from the MSP stable schema and protocol sources; do not edit by hand.
2
3use serde::Deserialize;
4use serde::Deserializer;
5use serde::Serialize;
6use serde::Serializer;
7
8/// What holds a tool call before it is admitted to execute. Open: a client
9/// reads an unknown value as held by something it does not know, never as
10/// released.
11#[derive(Debug, Clone, PartialEq, Eq)]
12#[non_exhaustive]
13pub enum HeldFor {
14    /// An approval prompt holds the call.
15    Approval,
16    /// A pre-tool hook holds the call.
17    Hook,
18    /// A value from a newer host, kept verbatim so the call still reads as
19    /// held. Excluded from the generated schema; never construct it with a
20    /// known word.
21    Unknown(String),
22}
23
24impl HeldFor {
25    /// The exact wire spelling, including a value from a newer host.
26    #[must_use]
27    pub fn as_str(&self) -> &str {
28        match self {
29            Self::Approval => "approval",
30            Self::Hook => "hook",
31            Self::Unknown(value) => value,
32        }
33    }
34}
35
36impl Serialize for HeldFor {
37    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
38    where
39        S: Serializer,
40    {
41        serializer.serialize_str(self.as_str())
42    }
43}
44
45impl<'de> Deserialize<'de> for HeldFor {
46    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
47    where
48        D: Deserializer<'de>,
49    {
50        let value = String::deserialize(deserializer)?;
51        Ok(match value.as_str() {
52            "approval" => Self::Approval,
53            "hook" => Self::Hook,
54            _ => Self::Unknown(value),
55        })
56    }
57}