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