Skip to main content

muse_code_sdk/msp/method/hook/
catch_all.rs

1// @generated from the MSP stable schema and protocol sources; do not edit by hand.
2
3use super::{HookEventName, HookHandlerKind};
4use serde::{Deserialize, Deserializer, Serialize, Serializer};
5
6impl HookHandlerKind {
7    /// The exact wire spelling, including an unknown word kept verbatim.
8    pub fn as_str(&self) -> &str {
9        match self {
10            Self::Managed => "managed",
11            Self::User => "user",
12            Self::Project => "project",
13            Self::Plugin => "plugin",
14            Self::Unknown(word) => word,
15        }
16    }
17}
18
19impl Serialize for HookHandlerKind {
20    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21        serializer.serialize_str(self.as_str())
22    }
23}
24
25impl<'de> Deserialize<'de> for HookHandlerKind {
26    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
27        let word = String::deserialize(deserializer)?;
28        Ok(match word.as_str() {
29            "managed" => Self::Managed,
30            "user" => Self::User,
31            "project" => Self::Project,
32            "plugin" => Self::Plugin,
33            _ => Self::Unknown(word),
34        })
35    }
36}
37
38impl HookEventName {
39    /// The exact wire spelling, including an unknown word kept verbatim.
40    pub fn as_str(&self) -> &str {
41        match self {
42            Self::SessionStart => "sessionStart",
43            Self::UserPromptSubmit => "userPromptSubmit",
44            Self::PreToolUse => "preToolUse",
45            Self::PermissionRequest => "permissionRequest",
46            Self::PostToolUse => "postToolUse",
47            Self::PreLLMCall => "preLLMCall",
48            Self::PostLLMCall => "postLLMCall",
49            Self::PreCompact => "preCompact",
50            Self::PostCompact => "postCompact",
51            Self::SubagentStart => "subagentStart",
52            Self::SubagentStop => "subagentStop",
53            Self::Stop => "stop",
54            Self::SessionEnd => "sessionEnd",
55            Self::Notification => "notification",
56            Self::PostToolUseFailure => "postToolUseFailure",
57            Self::StopFailure => "stopFailure",
58            Self::PostToolBatch => "postToolBatch",
59            Self::Interrupt => "interrupt",
60            Self::SessionFork => "sessionFork",
61            Self::ToolUseStart => "toolUseStart",
62            Self::Unknown(word) => word,
63        }
64    }
65}
66
67impl Serialize for HookEventName {
68    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
69        serializer.serialize_str(self.as_str())
70    }
71}
72
73impl<'de> Deserialize<'de> for HookEventName {
74    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
75        let word = String::deserialize(deserializer)?;
76        Ok(match word.as_str() {
77            "sessionStart" => Self::SessionStart,
78            "userPromptSubmit" => Self::UserPromptSubmit,
79            "preToolUse" => Self::PreToolUse,
80            "permissionRequest" => Self::PermissionRequest,
81            "postToolUse" => Self::PostToolUse,
82            "preLLMCall" => Self::PreLLMCall,
83            "postLLMCall" => Self::PostLLMCall,
84            "preCompact" => Self::PreCompact,
85            "postCompact" => Self::PostCompact,
86            "subagentStart" => Self::SubagentStart,
87            "subagentStop" => Self::SubagentStop,
88            "stop" => Self::Stop,
89            "sessionEnd" => Self::SessionEnd,
90            "notification" => Self::Notification,
91            "postToolUseFailure" => Self::PostToolUseFailure,
92            "stopFailure" => Self::StopFailure,
93            "postToolBatch" => Self::PostToolBatch,
94            "interrupt" => Self::Interrupt,
95            "sessionFork" => Self::SessionFork,
96            "toolUseStart" => Self::ToolUseStart,
97            _ => Self::Unknown(word),
98        })
99    }
100}