1#[derive(serde::Serialize, serde::Deserialize)]
4#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
5#[repr(i32)]
6pub enum EscalatedPrivilege {
7 All = 0,
8 ReloadPlugin = 1,
9 LoadPlugin = 2,
10 UnloadPlugin = 3,
11 InstructPlugin = 4,
12}
13impl EscalatedPrivilege {
14 pub fn as_str_name(&self) -> &'static str {
19 match self {
20 EscalatedPrivilege::All => "ALL",
21 EscalatedPrivilege::ReloadPlugin => "RELOAD_PLUGIN",
22 EscalatedPrivilege::LoadPlugin => "LOAD_PLUGIN",
23 EscalatedPrivilege::UnloadPlugin => "UNLOAD_PLUGIN",
24 EscalatedPrivilege::InstructPlugin => "INSTRUCT_PLUGIN",
25 }
26 }
27 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
29 match value {
30 "ALL" => Some(Self::All),
31 "RELOAD_PLUGIN" => Some(Self::ReloadPlugin),
32 "LOAD_PLUGIN" => Some(Self::LoadPlugin),
33 "UNLOAD_PLUGIN" => Some(Self::UnloadPlugin),
34 "INSTRUCT_PLUGIN" => Some(Self::InstructPlugin),
35 _ => None,
36 }
37 }
38}
39#[derive(serde::Serialize, serde::Deserialize)]
41#[cfg_attr(feature = "builder", derive(derive_builder::Builder))]
42#[cfg_attr(feature = "builder", builder(default, setter(into, strip_option), custom_constructor, build_fn(name = "fallible_build")))]
43#[serde(default)]
44#[derive(Clone, PartialEq, ::prost::Message)]
45pub struct Argument {
46 #[prost(string, tag="1")]
48 pub name: ::prost::alloc::string::String,
49 #[prost(string, tag="2")]
51 pub description: ::prost::alloc::string::String,
52 #[prost(string, optional, tag="3")]
54 pub default_value: ::core::option::Option<::prost::alloc::string::String>,
55 #[prost(bool, tag="4")]
57 pub required: bool,
58 #[prost(string, optional, tag="5")]
60 pub short: ::core::option::Option<::prost::alloc::string::String>,
61 #[prost(string, optional, tag="6")]
63 pub long: ::core::option::Option<::prost::alloc::string::String>,
64}
65#[derive(serde::Serialize, serde::Deserialize)]
67#[cfg_attr(feature = "builder", derive(derive_builder::Builder))]
68#[cfg_attr(feature = "builder", builder(default, setter(into, strip_option), custom_constructor, build_fn(name = "fallible_build")))]
69#[serde(default)]
70#[derive(Clone, PartialEq, ::prost::Message)]
71pub struct Command {
72 #[prost(string, tag="1")]
74 pub name: ::prost::alloc::string::String,
75 #[prost(string, tag="2")]
77 pub description: ::prost::alloc::string::String,
78 #[prost(string, optional, tag="3")]
80 pub author: ::core::option::Option<::prost::alloc::string::String>,
81 #[prost(string, optional, tag="4")]
85 pub version: ::core::option::Option<::prost::alloc::string::String>,
86 #[prost(string, repeated, tag="5")]
88 pub aliases: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
89 #[prost(message, repeated, tag="6")]
91 pub arguments: ::prost::alloc::vec::Vec<Argument>,
92 #[prost(message, repeated, tag="7")]
94 pub subcommands: ::prost::alloc::vec::Vec<Command>,
95 #[prost(message, optional, tag="8")]
99 pub access_checks: ::core::option::Option<super::access_check::AccessCheckChain>,
100 #[prost(bool, tag="9")]
104 pub arg_required_else_help: bool,
105}
106#[cfg_attr(feature = "kameo", derive(kameo::Reply))]
108#[derive(serde::Serialize, serde::Deserialize)]
109#[cfg_attr(feature = "builder", derive(derive_builder::Builder))]
110#[cfg_attr(feature = "builder", builder(default, setter(into, strip_option), custom_constructor, build_fn(name = "fallible_build")))]
111#[serde(default)]
112#[derive(Clone, PartialEq, ::prost::Message)]
113pub struct Metadata {
114 #[prost(string, tag="1")]
116 pub name: ::prost::alloc::string::String,
117 #[prost(string, tag="2")]
119 pub description: ::prost::alloc::string::String,
120 #[prost(string, tag="3")]
124 pub version: ::prost::alloc::string::String,
125 #[prost(bool, tag="4")]
128 pub database: bool,
129 #[prost(message, optional, tag="5")]
133 #[cfg_attr(feature = "builder", builder(setter(custom)))]
134 pub access_checks: ::core::option::Option<super::access_check::AccessCheckChain>,
135 #[prost(string, optional, tag="6")]
138 #[cfg_attr(feature = "builder", builder(setter(custom)))]
139 pub escalation_key: ::core::option::Option<::prost::alloc::string::String>,
140 #[prost(enumeration="EscalatedPrivilege", repeated, tag="7")]
142 #[cfg_attr(feature = "builder", builder(setter(custom)))]
143 pub escalated_privileges: ::prost::alloc::vec::Vec<i32>,
144 #[prost(string, tag="8")]
146 pub author: ::prost::alloc::string::String,
147 #[prost(bool, tag="9")]
149 pub handles_commands: bool,
150 #[prost(bool, tag="10")]
152 pub handles_messages: bool,
153 #[prost(string, optional, tag="11")]
155 pub command_name: ::core::option::Option<::prost::alloc::string::String>,
156 #[prost(string, repeated, tag="12")]
158 #[cfg_attr(feature = "builder", builder(setter(custom)))]
159 pub aliases: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
160 #[prost(message, repeated, tag="13")]
162 pub arguments: ::prost::alloc::vec::Vec<Argument>,
163 #[prost(message, repeated, tag="14")]
165 pub subcommands: ::prost::alloc::vec::Vec<Command>,
166 #[prost(string, repeated, tag="15")]
168 #[cfg_attr(feature = "builder", builder(setter(custom)))]
169 pub allowed_hosts: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
170 #[prost(int32, optional, tag="16")]
172 pub pool_size: ::core::option::Option<i32>,
173 #[prost(bool, tag="17")]
177 pub arg_required_else_help: bool,
178}
179#[derive(serde::Serialize, serde::Deserialize)]
181#[serde(default)]
182#[derive(Clone, PartialEq, ::prost::Message)]
183pub struct CommandContextArgument {
184 #[prost(string, tag="1")]
186 pub name: ::prost::alloc::string::String,
187 #[prost(string, tag="2")]
189 pub value: ::prost::alloc::string::String,
190}
191#[derive(serde::Serialize, serde::Deserialize)]
193#[serde(default)]
194#[derive(Clone, PartialEq, ::prost::Message)]
195pub struct CommandContext {
196 #[prost(string, tag="1")]
198 pub name: ::prost::alloc::string::String,
199 #[prost(message, repeated, tag="2")]
201 pub arguments: ::prost::alloc::vec::Vec<CommandContextArgument>,
202 #[prost(message, optional, boxed, tag="3")]
204 pub subcommand: ::core::option::Option<::prost::alloc::boxed::Box<CommandContext>>,
205}
206#[derive(serde::Serialize, serde::Deserialize)]
208#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
209#[repr(i32)]
210pub enum InstructionKind {
211 Plugin = 0,
213 GetMetadata = 1,
215 Install = 2,
217 Initialize = 3,
219 Shutdown = 4,
221 ChatMessage = 5,
223 ChatCommand = 6,
225 ScheduledJob = 7,
227}
228impl InstructionKind {
229 pub fn as_str_name(&self) -> &'static str {
234 match self {
235 InstructionKind::Plugin => "Plugin",
236 InstructionKind::GetMetadata => "GetMetadata",
237 InstructionKind::Install => "Install",
238 InstructionKind::Initialize => "Initialize",
239 InstructionKind::Shutdown => "Shutdown",
240 InstructionKind::ChatMessage => "ChatMessage",
241 InstructionKind::ChatCommand => "ChatCommand",
242 InstructionKind::ScheduledJob => "ScheduledJob",
243 }
244 }
245 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
247 match value {
248 "Plugin" => Some(Self::Plugin),
249 "GetMetadata" => Some(Self::GetMetadata),
250 "Install" => Some(Self::Install),
251 "Initialize" => Some(Self::Initialize),
252 "Shutdown" => Some(Self::Shutdown),
253 "ChatMessage" => Some(Self::ChatMessage),
254 "ChatCommand" => Some(Self::ChatCommand),
255 "ScheduledJob" => Some(Self::ScheduledJob),
256 _ => None,
257 }
258 }
259}
260#[derive(serde::Serialize, serde::Deserialize)]
262#[serde(default)]
263#[derive(Clone, PartialEq, ::prost::Message)]
264pub struct Instruction {
265 #[prost(enumeration="InstructionKind", tag="1")]
267 pub kind: i32,
268 #[prost(bytes="vec", tag="2")]
270 pub input: ::prost::alloc::vec::Vec<u8>,
271 #[prost(string, optional, tag="3")]
273 pub target: ::core::option::Option<::prost::alloc::string::String>,
274}
275#[cfg(feature = "builder")]
278#[derive(Debug)]
279pub enum AccessChecks {
280 Array(Vec<crate::access_check::AccessCheck>),
281 Single(crate::access_check::AccessCheck),
282 Full(crate::access_check::AccessCheckChain),
283}
284#[cfg(feature = "builder")]
285impl Metadata {
286 pub fn new(
287 name: impl Into<String>,
288 author: impl Into<String>,
289 description: impl Into<String>,
290 version: impl Into<String>,
291 ) -> MetadataBuilder {
292 MetadataBuilder {
293 name: Some(name.into()),
294 author: Some(author.into()),
295 description: Some(description.into()),
296 version: Some(version.into()),
297 ..MetadataBuilder::create_empty()
298 }
299 }
300}
301#[cfg(feature = "builder")]
302impl MetadataBuilder {
303 pub fn allowed_hosts(
304 &mut self,
305 value: impl IntoIterator<Item = impl Into<String>>,
306 ) -> &mut Self {
307 self.allowed_hosts = Some(value.into_iter().map(Into::into).collect());
308 self
309 }
310 pub fn aliases(&mut self, value: impl IntoIterator<Item = impl Into<String>>) -> &mut Self {
311 self.aliases = Some(value.into_iter().map(Into::into).collect());
312 self
313 }
314 pub fn escalation_key(&mut self, value: impl Into<String>) -> &mut Self {
315 self.escalation_key = Some(Some(value.into()));
316 self
317 }
318 pub fn escalated_privileges(
319 &mut self,
320 value: impl IntoIterator<Item = impl Into<i32>>,
321 ) -> &mut Self {
322 self.escalated_privileges = Some(value.into_iter().map(Into::into).collect());
323 self
324 }
325 pub fn access_checks(&mut self, value: AccessChecks) -> &mut Self {
326 self.access_checks = Some(match value {
327 AccessChecks::Array(checks) => Some(crate::access_check::AccessCheckChain {
328 operator: crate::access_check::AccessCheckOperator::Or.into(),
329 checks,
330 }),
331 AccessChecks::Single(check) => Some(crate::access_check::AccessCheckChain {
332 operator: crate::access_check::AccessCheckOperator::Or.into(),
333 checks: vec![check],
334 }),
335 AccessChecks::Full(full) => Some(full),
336 });
337 self
338 }
339 pub fn build(&self) -> Metadata {
340 self.fallible_build()
341 .expect("All required fields were initialized")
342 }
343}
344#[cfg(feature = "builder")]
345impl Command {
346 pub fn new(name: impl Into<String>, description: impl Into<String>) -> CommandBuilder {
347 CommandBuilder {
348 name: Some(name.into()),
349 description: Some(description.into()),
350 ..CommandBuilder::create_empty()
351 }
352 }
353}
354#[cfg(feature = "builder")]
355impl CommandBuilder {
356 pub fn build(&self) -> Command {
357 self.fallible_build()
358 .expect("All required fields were initialized")
359 }
360}
361#[cfg(feature = "builder")]
362impl Argument {
363 pub fn new(name: impl Into<String>, description: impl Into<String>) -> ArgumentBuilder {
364 ArgumentBuilder {
365 name: Some(name.into()),
366 description: Some(description.into()),
367 ..ArgumentBuilder::create_empty()
368 }
369 }
370}
371#[cfg(feature = "builder")]
372impl ArgumentBuilder {
373 pub fn build(&self) -> Argument {
374 self.fallible_build()
375 .expect("All required fields were initialized")
376 }
377}