#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum EscalatedPrivilege {
All = 0,
ReloadPlugin = 1,
LoadPlugin = 2,
UnloadPlugin = 3,
InstructPlugin = 4,
}
impl EscalatedPrivilege {
pub fn as_str_name(&self) -> &'static str {
match self {
EscalatedPrivilege::All => "ALL",
EscalatedPrivilege::ReloadPlugin => "RELOAD_PLUGIN",
EscalatedPrivilege::LoadPlugin => "LOAD_PLUGIN",
EscalatedPrivilege::UnloadPlugin => "UNLOAD_PLUGIN",
EscalatedPrivilege::InstructPlugin => "INSTRUCT_PLUGIN",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"ALL" => Some(Self::All),
"RELOAD_PLUGIN" => Some(Self::ReloadPlugin),
"LOAD_PLUGIN" => Some(Self::LoadPlugin),
"UNLOAD_PLUGIN" => Some(Self::UnloadPlugin),
"INSTRUCT_PLUGIN" => Some(Self::InstructPlugin),
_ => None,
}
}
}
#[derive(serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "builder", derive(derive_builder::Builder))]
#[cfg_attr(feature = "builder", builder(default, setter(into, strip_option), custom_constructor, build_fn(name = "fallible_build")))]
#[serde(default)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Argument {
#[prost(string, tag="1")]
pub name: ::prost::alloc::string::String,
#[prost(string, tag="2")]
pub description: ::prost::alloc::string::String,
#[prost(string, optional, tag="3")]
pub default_value: ::core::option::Option<::prost::alloc::string::String>,
#[prost(bool, tag="4")]
pub required: bool,
#[prost(string, optional, tag="5")]
pub short: ::core::option::Option<::prost::alloc::string::String>,
#[prost(string, optional, tag="6")]
pub long: ::core::option::Option<::prost::alloc::string::String>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "builder", derive(derive_builder::Builder))]
#[cfg_attr(feature = "builder", builder(default, setter(into, strip_option), custom_constructor, build_fn(name = "fallible_build")))]
#[serde(default)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Command {
#[prost(string, tag="1")]
pub name: ::prost::alloc::string::String,
#[prost(string, tag="2")]
pub description: ::prost::alloc::string::String,
#[prost(string, optional, tag="3")]
pub author: ::core::option::Option<::prost::alloc::string::String>,
#[prost(string, optional, tag="4")]
pub version: ::core::option::Option<::prost::alloc::string::String>,
#[prost(string, repeated, tag="5")]
pub aliases: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(message, repeated, tag="6")]
pub arguments: ::prost::alloc::vec::Vec<Argument>,
#[prost(message, repeated, tag="7")]
pub subcommands: ::prost::alloc::vec::Vec<Command>,
#[prost(message, optional, tag="8")]
pub access_checks: ::core::option::Option<super::access_check::AccessCheckChain>,
}
#[cfg_attr(feature = "kameo", derive(kameo::Reply))]
#[derive(serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "builder", derive(derive_builder::Builder))]
#[cfg_attr(feature = "builder", builder(default, setter(into, strip_option), custom_constructor, build_fn(name = "fallible_build")))]
#[serde(default)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Metadata {
#[prost(string, tag="1")]
pub name: ::prost::alloc::string::String,
#[prost(string, tag="2")]
pub description: ::prost::alloc::string::String,
#[prost(string, tag="3")]
pub version: ::prost::alloc::string::String,
#[prost(bool, tag="4")]
pub database: bool,
#[prost(message, optional, tag="5")]
#[cfg_attr(feature = "builder", builder(setter(custom)))]
pub access_checks: ::core::option::Option<super::access_check::AccessCheckChain>,
#[prost(string, optional, tag="6")]
#[cfg_attr(feature = "builder", builder(setter(custom)))]
pub escalation_key: ::core::option::Option<::prost::alloc::string::String>,
#[prost(enumeration="EscalatedPrivilege", repeated, tag="7")]
#[cfg_attr(feature = "builder", builder(setter(custom)))]
pub escalated_privileges: ::prost::alloc::vec::Vec<i32>,
#[prost(string, tag="8")]
pub author: ::prost::alloc::string::String,
#[prost(bool, tag="9")]
pub handles_commands: bool,
#[prost(bool, tag="10")]
pub handles_messages: bool,
#[prost(string, optional, tag="11")]
pub command_name: ::core::option::Option<::prost::alloc::string::String>,
#[prost(string, repeated, tag="12")]
#[cfg_attr(feature = "builder", builder(setter(custom)))]
pub aliases: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(message, repeated, tag="13")]
pub arguments: ::prost::alloc::vec::Vec<Argument>,
#[prost(message, repeated, tag="14")]
pub subcommands: ::prost::alloc::vec::Vec<Command>,
#[prost(string, repeated, tag="15")]
pub allowed_hosts: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(int32, optional, tag="16")]
pub pool_size: ::core::option::Option<i32>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(default)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CommandContextArgument {
#[prost(string, tag="1")]
pub name: ::prost::alloc::string::String,
#[prost(string, tag="2")]
pub value: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(default)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CommandContext {
#[prost(string, tag="1")]
pub name: ::prost::alloc::string::String,
#[prost(message, repeated, tag="2")]
pub arguments: ::prost::alloc::vec::Vec<CommandContextArgument>,
#[prost(message, optional, boxed, tag="3")]
pub subcommand: ::core::option::Option<::prost::alloc::boxed::Box<CommandContext>>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum InstructionKind {
Plugin = 0,
GetMetadata = 1,
Install = 2,
Initialize = 3,
Shutdown = 4,
ChatMessage = 5,
ChatCommand = 6,
ScheduledJob = 7,
}
impl InstructionKind {
pub fn as_str_name(&self) -> &'static str {
match self {
InstructionKind::Plugin => "Plugin",
InstructionKind::GetMetadata => "GetMetadata",
InstructionKind::Install => "Install",
InstructionKind::Initialize => "Initialize",
InstructionKind::Shutdown => "Shutdown",
InstructionKind::ChatMessage => "ChatMessage",
InstructionKind::ChatCommand => "ChatCommand",
InstructionKind::ScheduledJob => "ScheduledJob",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"Plugin" => Some(Self::Plugin),
"GetMetadata" => Some(Self::GetMetadata),
"Install" => Some(Self::Install),
"Initialize" => Some(Self::Initialize),
"Shutdown" => Some(Self::Shutdown),
"ChatMessage" => Some(Self::ChatMessage),
"ChatCommand" => Some(Self::ChatCommand),
"ScheduledJob" => Some(Self::ScheduledJob),
_ => None,
}
}
}
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(default)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Instruction {
#[prost(enumeration="InstructionKind", tag="1")]
pub kind: i32,
#[prost(bytes="vec", tag="2")]
pub input: ::prost::alloc::vec::Vec<u8>,
#[prost(string, optional, tag="3")]
pub target: ::core::option::Option<::prost::alloc::string::String>,
}
#[cfg(feature = "builder")]
#[derive(Debug)]
pub enum AccessChecks {
Array(Vec<crate::access_check::AccessCheck>),
Single(crate::access_check::AccessCheck),
Full(crate::access_check::AccessCheckChain),
}
#[cfg(feature = "builder")]
impl Metadata {
pub fn new(
name: impl Into<String>,
author: impl Into<String>,
description: impl Into<String>,
version: impl Into<String>,
) -> MetadataBuilder {
MetadataBuilder {
name: Some(name.into()),
author: Some(author.into()),
description: Some(description.into()),
version: Some(version.into()),
..MetadataBuilder::create_empty()
}
}
}
#[cfg(feature = "builder")]
impl MetadataBuilder {
pub fn aliases(&mut self, value: impl IntoIterator<Item = impl Into<String>>) -> &mut Self {
self.aliases = Some(value.into_iter().map(Into::into).collect());
self
}
pub fn escalation_key(&mut self, value: impl Into<String>) -> &mut Self {
self.escalation_key = Some(Some(value.into()));
self
}
pub fn escalated_privileges(
&mut self,
value: impl IntoIterator<Item = impl Into<i32>>,
) -> &mut Self {
self.escalated_privileges = Some(value.into_iter().map(Into::into).collect());
self
}
pub fn access_checks(&mut self, value: AccessChecks) -> &mut Self {
self.access_checks = Some(match value {
AccessChecks::Array(checks) => Some(crate::access_check::AccessCheckChain {
operator: crate::access_check::AccessCheckOperator::Or.into(),
checks,
}),
AccessChecks::Single(check) => Some(crate::access_check::AccessCheckChain {
operator: crate::access_check::AccessCheckOperator::Or.into(),
checks: vec![check],
}),
AccessChecks::Full(full) => Some(full),
});
self
}
pub fn build(&self) -> Metadata {
self.fallible_build()
.expect("All required fields were initialized")
}
}
#[cfg(feature = "builder")]
impl Command {
pub fn new(name: impl Into<String>, description: impl Into<String>) -> CommandBuilder {
CommandBuilder {
name: Some(name.into()),
description: Some(description.into()),
..CommandBuilder::create_empty()
}
}
}
#[cfg(feature = "builder")]
impl CommandBuilder {
pub fn build(&self) -> Command {
self.fallible_build()
.expect("All required fields were initialized")
}
}
#[cfg(feature = "builder")]
impl Argument {
pub fn new(name: impl Into<String>, description: impl Into<String>) -> ArgumentBuilder {
ArgumentBuilder {
name: Some(name.into()),
description: Some(description.into()),
..ArgumentBuilder::create_empty()
}
}
}
#[cfg(feature = "builder")]
impl ArgumentBuilder {
pub fn build(&self) -> Argument {
self.fallible_build()
.expect("All required fields were initialized")
}
}