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. Bound by the governing rules to
56 /// `status` `rejected` or `failed`, never `completed` — the first such
57 /// binding, published as v1 contract text by the` amendment.
58 Rejected,
59 /// The Code Mode cell ran to its own completion; status `completed`.
60 Completed,
61 /// The Code Mode call returned while its cell was still running; the item
62 /// is `completed` — the cell's state, not the call's.
63 Pending,
64 /// The Code Mode cell or call failed; status `failed`.
65 Failed,
66 /// The Code Mode cell or wait timed out; status `timedOut`.
67 TimedOut,
68 /// The Code Mode cell or call was cancelled; status `cancelled`.
69 Cancelled,
70 /// A value minted by a newer decision than this build knows. Preserved
71 /// verbatim so a client falls back **only for the part it does not
72 /// recognize** and can still read the discriminators and family fields it
73 /// does understand. Not a value any family registered, so it is excluded
74 /// from the generated schema while the enum stays declared open — the
75 /// `SessionDurability::Unknown` shape.
76 ///
77 /// **Never construct this with a registered word.** Decoding never
78 /// produces it for one, so `Unknown("create")` does not survive a
79 /// round-trip: it re-decodes as the named variant and the two values
80 /// compare unequal. Producers build the named variant.
81 Unknown(String),
82}
83
84impl ToolReceiptOperation {
85 /// The exact wire spelling, including a value this build does not know.
86 #[must_use]
87 pub fn as_str(&self) -> &str {
88 match self {
89 Self::Create => "create",
90 Self::Delete => "delete",
91 Self::List => "list",
92 Self::Execute => "execute",
93 Self::Wait => "wait",
94 Self::Unknown(value) => value,
95 }
96 }
97}
98
99impl Serialize for ToolReceiptOperation {
100 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
101 where
102 S: Serializer,
103 {
104 serializer.serialize_str(self.as_str())
105 }
106}
107
108impl<'de> Deserialize<'de> for ToolReceiptOperation {
109 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
110 where
111 D: Deserializer<'de>,
112 {
113 let value = String::deserialize(deserializer)?;
114 Ok(match value.as_str() {
115 "create" => Self::Create,
116 "delete" => Self::Delete,
117 "list" => Self::List,
118 "execute" => Self::Execute,
119 "wait" => Self::Wait,
120 _ => Self::Unknown(value),
121 })
122 }
123}
124
125impl ToolReceiptOutcome {
126 /// The exact wire spelling, including a value this build does not know.
127 #[must_use]
128 pub fn as_str(&self) -> &str {
129 match self {
130 Self::Created => "created",
131 Self::Duplicate => "duplicate",
132 Self::Deleted => "deleted",
133 Self::Missing => "missing",
134 Self::Listed => "listed",
135 Self::Rejected => "rejected",
136 Self::Completed => "completed",
137 Self::Pending => "pending",
138 Self::Failed => "failed",
139 Self::TimedOut => "timedOut",
140 Self::Cancelled => "cancelled",
141 Self::Unknown(value) => value,
142 }
143 }
144}
145
146impl Serialize for ToolReceiptOutcome {
147 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
148 where
149 S: Serializer,
150 {
151 serializer.serialize_str(self.as_str())
152 }
153}
154
155impl<'de> Deserialize<'de> for ToolReceiptOutcome {
156 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
157 where
158 D: Deserializer<'de>,
159 {
160 let value = String::deserialize(deserializer)?;
161 Ok(match value.as_str() {
162 "created" => Self::Created,
163 "duplicate" => Self::Duplicate,
164 "deleted" => Self::Deleted,
165 "missing" => Self::Missing,
166 "listed" => Self::Listed,
167 "rejected" => Self::Rejected,
168 "completed" => Self::Completed,
169 "pending" => Self::Pending,
170 "failed" => Self::Failed,
171 "timedOut" => Self::TimedOut,
172 "cancelled" => Self::Cancelled,
173 _ => Self::Unknown(value),
174 })
175 }
176}