nomux_extension/generated/nomux.extension.v1.rs
1// This file is @generated by prost-build.
2/// Calls one method.
3#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
4pub struct CallRequest {
5 /// The name of the method.
6 ///
7 /// From the host: a method that the extension supplies, for example `echo`.
8 /// From the extension: a method of a host service in the form
9 /// `<service>.<method>`, for example `sessions.list`.
10 #[prost(string, tag = "1")]
11 pub method: ::prost::alloc::string::String,
12 /// The argument of the method. The method specifies the encoding. The Rust
13 /// SDK uses an encoded protobuf message.
14 #[prost(bytes = "vec", tag = "2")]
15 pub payload: ::prost::alloc::vec::Vec<u8>,
16}
17/// The reply to `CallRequest`.
18#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
19pub struct CallResponse {
20 /// The result of the method. The method specifies the encoding.
21 #[prost(bytes = "vec", tag = "1")]
22 pub payload: ::prost::alloc::vec::Vec<u8>,
23}
24/// A version of the extension API. The extension API uses Semantic Versioning
25/// 2.0.0 and its version is independent of the product version of nomux.
26#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
27pub struct ApiVersion {
28 /// The major version.
29 #[prost(uint32, tag = "1")]
30 pub major: u32,
31 /// The minor version.
32 #[prost(uint32, tag = "2")]
33 pub minor: u32,
34 /// The patch version.
35 #[prost(uint32, tag = "3")]
36 pub patch: u32,
37}
38/// The permissions that the user approved for the extension.
39///
40/// The source is the `\[permissions\]` table of `extension.toml`. The host
41/// applies the permissions. The extension reads them to know what it can do.
42#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
43pub struct Permissions {
44 /// The directories that the extension can read and write. Each item is an
45 /// absolute path. The host replaced each variable of the manifest, for
46 /// example `${worktree}`.
47 #[prost(string, repeated, tag = "1")]
48 pub fs: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
49 /// The programs that the extension can start. Each item is a program name.
50 #[prost(string, repeated, tag = "2")]
51 pub process: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
52 /// `true` if the extension can open network connections.
53 #[prost(bool, tag = "3")]
54 pub network: bool,
55 /// The scopes of host services that the extension can use, for example
56 /// `sessions:read`.
57 #[prost(string, repeated, tag = "4")]
58 pub scopes: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
59}
60/// The first message from the host.
61#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
62pub struct Hello {
63 /// The extension API version that the host supplies.
64 #[prost(message, optional, tag = "1")]
65 pub api_version: ::core::option::Option<ApiVersion>,
66 /// The identifier of the extension in its manifest, for example `nomux.git`.
67 #[prost(string, tag = "2")]
68 pub extension_id: ::prost::alloc::string::String,
69 /// The permissions that the extension has.
70 #[prost(message, optional, tag = "3")]
71 pub permissions: ::core::option::Option<Permissions>,
72}
73/// The reply from the extension to `Hello`.
74#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
75pub struct Welcome {
76 /// The extension API version that the extension was built for.
77 #[prost(message, optional, tag = "1")]
78 pub api_version: ::core::option::Option<ApiVersion>,
79 /// The identifier that the extension has in its code. The host stops the
80 /// extension if the value is different from the identifier in the manifest.
81 #[prost(string, tag = "2")]
82 pub extension_id: ::prost::alloc::string::String,
83 /// The version of the extension, for example `1.0.0`.
84 #[prost(string, tag = "3")]
85 pub extension_version: ::prost::alloc::string::String,
86}
87/// Tells the extension to prepare for calls. The host sends it one time, after
88/// the handshake and before the first call.
89#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
90pub struct InitializeRequest {}
91/// The reply to `InitializeRequest`. After it, the extension accepts calls.
92#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
93pub struct InitializeResponse {}
94/// Tells the extension to stop. The host sends it when the extension is idle
95/// or when the daemon stops.
96#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
97pub struct ShutdownRequest {}
98/// The reply to `ShutdownRequest`. The extension sends it and then exits.
99#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
100pub struct ShutdownResponse {}
101/// Asks the extension if it can still read and write messages.
102#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
103pub struct HealthRequest {}
104/// The reply to `HealthRequest`. An extension answers also while a call runs.
105#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
106pub struct HealthResponse {}
107/// The failure result of a request.
108#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
109pub struct Error {
110 /// The reason for the failure.
111 #[prost(enumeration = "ErrorCode", tag = "1")]
112 pub code: i32,
113 /// A message in English for the user. The text is not stable: a peer must
114 /// not parse it.
115 #[prost(string, tag = "2")]
116 pub message: ::prost::alloc::string::String,
117}
118/// A numbered request from one peer to the other peer.
119#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
120pub struct Request {
121 /// The request number. The sender selects the value. The value is not 0 and
122 /// is different from the `id` of each request of the same sender that has
123 /// no response yet. Each peer has its own numbers.
124 #[prost(uint64, tag = "1")]
125 pub id: u64,
126 /// The request body. See the field number plan at the top of this file.
127 #[prost(oneof = "request::Body", tags = "100, 200, 201, 202, 300")]
128 pub body: ::core::option::Option<request::Body>,
129}
130/// Nested message and enum types in `Request`.
131pub mod request {
132 /// The request body. See the field number plan at the top of this file.
133 #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
134 pub enum Body {
135 /// Handshake: the first request. Only the host sends it.
136 #[prost(message, tag = "100")]
137 Hello(super::Hello),
138 /// Life cycle: prepare for calls. Only the host sends it.
139 #[prost(message, tag = "200")]
140 Initialize(super::InitializeRequest),
141 /// Life cycle: stop. Only the host sends it.
142 #[prost(message, tag = "201")]
143 Shutdown(super::ShutdownRequest),
144 /// Life cycle: liveness check. Only the host sends it.
145 #[prost(message, tag = "202")]
146 Health(super::HealthRequest),
147 /// A call. The host calls a method of the extension, or the extension
148 /// calls a method of a host service.
149 #[prost(message, tag = "300")]
150 Call(super::CallRequest),
151 }
152}
153/// The response to one request.
154#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
155pub struct Response {
156 /// The `id` of the request that this response answers.
157 #[prost(uint64, tag = "1")]
158 pub id: u64,
159 /// The result of the request. See the field number plan at the top of this
160 /// file.
161 #[prost(oneof = "response::Result", tags = "2, 100, 200, 201, 202, 300")]
162 pub result: ::core::option::Option<response::Result>,
163}
164/// Nested message and enum types in `Response`.
165pub mod response {
166 /// The result of the request. See the field number plan at the top of this
167 /// file.
168 #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
169 pub enum Result {
170 /// The request failed.
171 #[prost(message, tag = "2")]
172 Error(super::Error),
173 /// Handshake: the reply to `Hello`.
174 #[prost(message, tag = "100")]
175 Welcome(super::Welcome),
176 /// The reply to `InitializeRequest`.
177 #[prost(message, tag = "200")]
178 Initialize(super::InitializeResponse),
179 /// The reply to `ShutdownRequest`.
180 #[prost(message, tag = "201")]
181 Shutdown(super::ShutdownResponse),
182 /// The reply to `HealthRequest`.
183 #[prost(message, tag = "202")]
184 Health(super::HealthResponse),
185 /// The reply to `CallRequest`.
186 #[prost(message, tag = "300")]
187 Call(super::CallResponse),
188 }
189}
190/// A message from the extension that no request asked for.
191#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
192pub struct Event {
193 /// The name of the event. The extension selects the name. The host adds the
194 /// identifier of the extension, thus two extensions can use the same name.
195 #[prost(string, tag = "1")]
196 pub name: ::prost::alloc::string::String,
197 /// The data of the event. The host does not read it.
198 #[prost(bytes = "vec", tag = "2")]
199 pub payload: ::prost::alloc::vec::Vec<u8>,
200}
201/// Tells the receiver to stop a request.
202#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
203pub struct Cancel {
204 /// The `id` of a request that the sender of this message sent before.
205 #[prost(uint64, tag = "1")]
206 pub id: u64,
207}
208/// One message between the host and the extension.
209#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
210pub struct Envelope {
211 /// The content of the envelope.
212 #[prost(oneof = "envelope::Kind", tags = "1, 2, 3, 4")]
213 pub kind: ::core::option::Option<envelope::Kind>,
214}
215/// Nested message and enum types in `Envelope`.
216pub mod envelope {
217 /// The content of the envelope.
218 #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
219 pub enum Kind {
220 /// A request.
221 #[prost(message, tag = "1")]
222 Request(super::Request),
223 /// The response to a request of the other peer.
224 #[prost(message, tag = "2")]
225 Response(super::Response),
226 /// An event from the extension.
227 #[prost(message, tag = "3")]
228 Event(super::Event),
229 /// The cancellation of a request.
230 #[prost(message, tag = "4")]
231 Cancel(super::Cancel),
232 }
233}
234/// The reason for a failed request.
235///
236/// The values 1 to 5 are equal to the values of `ErrorCode` in the nomux
237/// control protocol (package `nomux.wire.v1`).
238#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
239#[repr(i32)]
240pub enum ErrorCode {
241 /// The sender did not set the field. The receiver treats this as
242 /// `ERROR_CODE_FAILED`. The receiver does the same for a value that it does
243 /// not know.
244 Unspecified = 0,
245 /// The request failed, and no other code gives the reason.
246 Failed = 1,
247 /// The method or the item that the request names does not exist.
248 NotFound = 2,
249 /// The receiver did not complete the request in the permitted time.
250 Timeout = 3,
251 /// The extension does not have the permission that the request needs.
252 PermissionDenied = 4,
253 /// The host does not supply the extension API version that the extension
254 /// needs. Only the reply to `Hello` uses this code.
255 VersionIncompatible = 5,
256 /// The receiver cannot read the payload of the request.
257 InvalidArgument = 6,
258 /// The receiver stopped the request because the sender sent `Cancel`.
259 Cancelled = 7,
260}
261impl ErrorCode {
262 /// String value of the enum field names used in the ProtoBuf definition.
263 ///
264 /// The values are not transformed in any way and thus are considered stable
265 /// (if the ProtoBuf definition does not change) and safe for programmatic use.
266 pub fn as_str_name(&self) -> &'static str {
267 match self {
268 Self::Unspecified => "ERROR_CODE_UNSPECIFIED",
269 Self::Failed => "ERROR_CODE_FAILED",
270 Self::NotFound => "ERROR_CODE_NOT_FOUND",
271 Self::Timeout => "ERROR_CODE_TIMEOUT",
272 Self::PermissionDenied => "ERROR_CODE_PERMISSION_DENIED",
273 Self::VersionIncompatible => "ERROR_CODE_VERSION_INCOMPATIBLE",
274 Self::InvalidArgument => "ERROR_CODE_INVALID_ARGUMENT",
275 Self::Cancelled => "ERROR_CODE_CANCELLED",
276 }
277 }
278 /// Creates an enum from field names used in the ProtoBuf definition.
279 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
280 match value {
281 "ERROR_CODE_UNSPECIFIED" => Some(Self::Unspecified),
282 "ERROR_CODE_FAILED" => Some(Self::Failed),
283 "ERROR_CODE_NOT_FOUND" => Some(Self::NotFound),
284 "ERROR_CODE_TIMEOUT" => Some(Self::Timeout),
285 "ERROR_CODE_PERMISSION_DENIED" => Some(Self::PermissionDenied),
286 "ERROR_CODE_VERSION_INCOMPATIBLE" => Some(Self::VersionIncompatible),
287 "ERROR_CODE_INVALID_ARGUMENT" => Some(Self::InvalidArgument),
288 "ERROR_CODE_CANCELLED" => Some(Self::Cancelled),
289 _ => None,
290 }
291 }
292}