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
58
59
60
61
62
63
// @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;
/// `subagentResult.resultStatus`: the consumed attempt's outcome. Absent when
/// the host had not seen that attempt's result envelope at the drain; a client
/// then shows the child's current outcome. Open: a client treats a value it
/// does not know as an absent member.
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum SubagentResultStatus {
/// The attempt finished normally (its envelope names no error, or the
/// generated child's model-step cap).
Completed,
/// The attempt failed (any other error the envelope names).
Failed,
/// The attempt was cancelled, for example by a redirect.
Cancelled,
/// A value from a newer host, kept verbatim so an older client decodes the
/// rest of the item. Excluded from the generated schema while the enum
/// stays declared open; never construct it with a known word.
Unknown(String),
}
impl SubagentResultStatus {
/// The exact wire spelling, including a value from a newer host.
#[must_use]
pub fn as_str(&self) -> &str {
match self {
Self::Completed => "completed",
Self::Failed => "failed",
Self::Cancelled => "cancelled",
Self::Unknown(value) => value,
}
}
}
impl Serialize for SubagentResultStatus {
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 SubagentResultStatus {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let value = String::deserialize(deserializer)?;
Ok(match value.as_str() {
"completed" => Self::Completed,
"failed" => Self::Failed,
"cancelled" => Self::Cancelled,
_ => Self::Unknown(value),
})
}
}