Skip to main content

muse_code_sdk/msp/view/
subagent_result_status.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/// `subagentResult.resultStatus`: the consumed attempt's outcome. Absent when
9/// the host had not seen that attempt's result envelope at the drain; a client
10/// then shows the child's current outcome. Open: a client treats a value it
11/// does not know as an absent member.
12#[derive(Debug, Clone, PartialEq, Eq)]
13#[non_exhaustive]
14pub enum SubagentResultStatus {
15    /// The attempt finished normally (its envelope names no error, or the
16    /// generated child's model-step cap).
17    Completed,
18    /// The attempt failed (any other error the envelope names).
19    Failed,
20    /// The attempt was cancelled, for example by a redirect.
21    Cancelled,
22    /// A value from a newer host, kept verbatim so an older client decodes the
23    /// rest of the item. Excluded from the generated schema while the enum
24    /// stays declared open; never construct it with a known word.
25    Unknown(String),
26}
27
28impl SubagentResultStatus {
29    /// The exact wire spelling, including a value from a newer host.
30    #[must_use]
31    pub fn as_str(&self) -> &str {
32        match self {
33            Self::Completed => "completed",
34            Self::Failed => "failed",
35            Self::Cancelled => "cancelled",
36            Self::Unknown(value) => value,
37        }
38    }
39}
40
41impl Serialize for SubagentResultStatus {
42    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
43    where
44        S: Serializer,
45    {
46        serializer.serialize_str(self.as_str())
47    }
48}
49
50impl<'de> Deserialize<'de> for SubagentResultStatus {
51    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
52    where
53        D: Deserializer<'de>,
54    {
55        let value = String::deserialize(deserializer)?;
56        Ok(match value.as_str() {
57            "completed" => Self::Completed,
58            "failed" => Self::Failed,
59            "cancelled" => Self::Cancelled,
60            _ => Self::Unknown(value),
61        })
62    }
63}