muse_code_sdk/msp/view/tool_receipt/vocabulary.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/// Which operation within the family the receipt describes. Open — registered
9/// per family, never derived from the tool name.
10#[derive(Debug, Clone, PartialEq, Eq)]
11#[non_exhaustive]
12pub enum ToolReceiptOperation {
13 /// `cron_create`.
14 Create,
15 /// `cron_delete`.
16 Delete,
17 /// `cron_list`.
18 List,
19 /// `code_exec` and its legacy alias `code.exec`.
20 Execute,
21 /// `code_wait` and its legacy alias `code.wait`.
22 Wait,
23 /// A value minted by a newer decision than this build knows. Preserved
24 /// verbatim so a client falls back **only for the part it does not
25 /// recognize** and can still read the discriminators and family fields it
26 /// does understand. Not a value any family registered, so it is excluded
27 /// from the generated schema while the enum stays declared open — the
28 /// `SessionDurability::Unknown` shape.
29 ///
30 /// **Never construct this with a registered word.** Decoding never
31 /// produces it for one, so `Unknown("create")` does not survive a
32 /// round-trip: it re-decodes as the named variant and the two values
33 /// compare unequal. Producers build the named variant.
34 Unknown(String),
35}
36
37/// What the operation did. Open, and a **single shared vocabulary**: a value
38/// appearing in two families means the same thing in both, which is why the
39/// permitted `status` values are bound to the value here rather than per
40/// family.
41#[derive(Debug, Clone, PartialEq, Eq)]
42#[non_exhaustive]
43pub enum ToolReceiptOutcome {
44 /// A job was created.
45 Created,
46 /// The create matched an existing job.
47 Duplicate,
48 /// A job was deleted.
49 Deleted,
50 /// The delete matched no job.
51 Missing,
52 /// The list was served.
53 Listed,
54 /// The call was refused before it ran — by a human at approval or by the
55 /// policy engine with no human in the loop. Its `status` is always
56 /// `rejected` or `failed`, never `completed`.
57 Rejected,
58 /// The Code Mode cell ran to its own completion; status `completed`.
59 Completed,
60 /// The Code Mode call returned while its cell was still running; the item
61 /// is `completed` — the cell's state, not the call's.
62 Pending,
63 /// The Code Mode cell or call failed; status `failed`.
64 Failed,
65 /// The Code Mode cell or wait timed out; status `timedOut`.
66 TimedOut,
67 /// The Code Mode cell or call was cancelled; status `cancelled`.
68 Cancelled,
69 /// A value minted by a newer decision than this build knows. Preserved
70 /// verbatim so a client falls back **only for the part it does not
71 /// recognize** and can still read the discriminators and family fields it
72 /// does understand. Not a value any family registered, so it is excluded
73 /// from the generated schema while the enum stays declared open — the
74 /// `SessionDurability::Unknown` shape.
75 ///
76 /// **Never construct this with a registered word.** Decoding never
77 /// produces it for one, so `Unknown("create")` does not survive a
78 /// round-trip: it re-decodes as the named variant and the two values
79 /// compare unequal. Producers build the named variant.
80 Unknown(String),
81}
82
83impl ToolReceiptOperation {
84 /// The exact wire spelling, including a value this build does not know.
85 #[must_use]
86 pub fn as_str(&self) -> &str {
87 match self {
88 Self::Create => "create",
89 Self::Delete => "delete",
90 Self::List => "list",
91 Self::Execute => "execute",
92 Self::Wait => "wait",
93 Self::Unknown(value) => value,
94 }
95 }
96}
97
98impl Serialize for ToolReceiptOperation {
99 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
100 where
101 S: Serializer,
102 {
103 serializer.serialize_str(self.as_str())
104 }
105}
106
107impl<'de> Deserialize<'de> for ToolReceiptOperation {
108 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
109 where
110 D: Deserializer<'de>,
111 {
112 let value = String::deserialize(deserializer)?;
113 Ok(match value.as_str() {
114 "create" => Self::Create,
115 "delete" => Self::Delete,
116 "list" => Self::List,
117 "execute" => Self::Execute,
118 "wait" => Self::Wait,
119 _ => Self::Unknown(value),
120 })
121 }
122}
123
124impl ToolReceiptOutcome {
125 /// The exact wire spelling, including a value this build does not know.
126 #[must_use]
127 pub fn as_str(&self) -> &str {
128 match self {
129 Self::Created => "created",
130 Self::Duplicate => "duplicate",
131 Self::Deleted => "deleted",
132 Self::Missing => "missing",
133 Self::Listed => "listed",
134 Self::Rejected => "rejected",
135 Self::Completed => "completed",
136 Self::Pending => "pending",
137 Self::Failed => "failed",
138 Self::TimedOut => "timedOut",
139 Self::Cancelled => "cancelled",
140 Self::Unknown(value) => value,
141 }
142 }
143}
144
145impl Serialize for ToolReceiptOutcome {
146 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
147 where
148 S: Serializer,
149 {
150 serializer.serialize_str(self.as_str())
151 }
152}
153
154impl<'de> Deserialize<'de> for ToolReceiptOutcome {
155 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
156 where
157 D: Deserializer<'de>,
158 {
159 let value = String::deserialize(deserializer)?;
160 Ok(match value.as_str() {
161 "created" => Self::Created,
162 "duplicate" => Self::Duplicate,
163 "deleted" => Self::Deleted,
164 "missing" => Self::Missing,
165 "listed" => Self::Listed,
166 "rejected" => Self::Rejected,
167 "completed" => Self::Completed,
168 "pending" => Self::Pending,
169 "failed" => Self::Failed,
170 "timedOut" => Self::TimedOut,
171 "cancelled" => Self::Cancelled,
172 _ => Self::Unknown(value),
173 })
174 }
175}