muse_code_sdk/msp/handshake/sandbox.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/// Whether this host can enforce the sandbox. A property of the host process,
9/// probed once at construction and identical for every session and every
10/// connection it serves — never requested, granted, or negotiated, which is why
11/// it is not a capability. Open: a future enforcement posture arrives as a new
12/// value, read by older clients as unknown.
13#[derive(Debug, Clone, PartialEq, Eq)]
14#[non_exhaustive]
15pub enum SandboxAvailability {
16 /// Enforcement is possible on this host.
17 Available,
18 /// Enforcement is truly impossible (user-namespace denial, no usable
19 /// backend including embedded) — never mere missing-PATH bwrap. The
20 /// cause rides [`SandboxUnavailableReason`], when the host sends one.
21 Unavailable,
22 /// A value introduced by a newer host. Preserved so an older client can
23 /// fall back to its own probe without failing the handshake. Not a v1
24 /// server-emission value, so it is excluded from the generated
25 /// known-value schema while the enum remains declared open.
26 Unknown(String),
27}
28
29impl SandboxAvailability {
30 /// The exact wire spelling, including a future value an older client does
31 /// not understand.
32 #[must_use]
33 pub fn as_str(&self) -> &str {
34 match self {
35 Self::Available => "available",
36 Self::Unavailable => "unavailable",
37 Self::Unknown(value) => value,
38 }
39 }
40}
41
42impl Serialize for SandboxAvailability {
43 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
44 where
45 S: Serializer,
46 {
47 serializer.serialize_str(self.as_str())
48 }
49}
50
51impl<'de> Deserialize<'de> for SandboxAvailability {
52 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
53 where
54 D: Deserializer<'de>,
55 {
56 let value = String::deserialize(deserializer)?;
57 Ok(match value.as_str() {
58 "available" => Self::Available,
59 "unavailable" => Self::Unavailable,
60 _ => Self::Unknown(value),
61 })
62 }
63}
64
65/// Why sandbox enforcement is impossible on this host. Sent only when
66/// [`SandboxAvailability`] is `unavailable`; a client MUST NOT infer a
67/// reason when none is sent. Open: a future reason arrives as a new
68/// value, read by older clients as unknown.
69#[derive(Debug, Clone, PartialEq, Eq)]
70#[non_exhaustive]
71pub enum SandboxUnavailableReason {
72 /// Bubblewrap exists but cannot create user namespaces.
73 UserNamespacesDenied,
74 /// No capability-valid system bwrap on PATH and no usable embedded
75 /// fallback.
76 BubblewrapUnavailable,
77 /// A value introduced by a newer host, preserved for the same reason
78 /// as [`SandboxAvailability::Unknown`].
79 Unknown(String),
80}
81
82impl SandboxUnavailableReason {
83 /// The exact wire spelling, including a future value an older client does
84 /// not understand.
85 #[must_use]
86 pub fn as_str(&self) -> &str {
87 match self {
88 Self::UserNamespacesDenied => "userNamespacesDenied",
89 Self::BubblewrapUnavailable => "bubblewrapUnavailable",
90 Self::Unknown(value) => value,
91 }
92 }
93}
94
95impl Serialize for SandboxUnavailableReason {
96 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
97 where
98 S: Serializer,
99 {
100 serializer.serialize_str(self.as_str())
101 }
102}
103
104impl<'de> Deserialize<'de> for SandboxUnavailableReason {
105 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
106 where
107 D: Deserializer<'de>,
108 {
109 let value = String::deserialize(deserializer)?;
110 Ok(match value.as_str() {
111 "userNamespacesDenied" => Self::UserNamespacesDenied,
112 "bubblewrapUnavailable" => Self::BubblewrapUnavailable,
113 _ => Self::Unknown(value),
114 })
115 }
116}