From 90020d013799cb081dab6c890dec3ecfc4af165d Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Mon, 10 Apr 2023 14:19:31 +0200 Subject: [PATCH] create new folder structure to map api routes --- src/api/mod.rs | 3 + src/api/policies/instance/limits.rs | 100 ++++++++++++++++++++++++++++ src/api/policies/instance/mod.rs | 5 ++ src/api/policies/mod.rs | 3 + 4 files changed, 111 insertions(+) create mode 100644 src/api/mod.rs create mode 100644 src/api/policies/instance/limits.rs create mode 100644 src/api/policies/instance/mod.rs create mode 100644 src/api/policies/mod.rs diff --git a/src/api/mod.rs b/src/api/mod.rs new file mode 100644 index 0000000..0d7b94c --- /dev/null +++ b/src/api/mod.rs @@ -0,0 +1,3 @@ +pub mod policies; + +pub use policies::instance::limits::*; diff --git a/src/api/policies/instance/limits.rs b/src/api/policies/instance/limits.rs new file mode 100644 index 0000000..770aa78 --- /dev/null +++ b/src/api/policies/instance/limits.rs @@ -0,0 +1,100 @@ +pub mod limits { + use serde::{Deserialize, Serialize}; + #[derive(Debug, Deserialize, Serialize)] + #[allow(non_snake_case)] + pub struct User { + pub maxGuilds: u64, + pub maxUsername: u64, + pub maxFriends: u64, + } + + #[derive(Debug, Deserialize, Serialize)] + #[allow(non_snake_case)] + + pub struct Guild { + pub maxRoles: u64, + pub maxEmojis: u64, + pub maxMembers: u64, + pub maxChannels: u64, + pub maxChannelsInCategory: u64, + } + + #[derive(Debug, Deserialize, Serialize)] + #[allow(non_snake_case)] + + pub struct Message { + pub maxCharacters: u64, + pub maxTTSCharacters: u64, + pub maxReactions: u64, + pub maxAttachmentSize: u64, + pub maxBulkDelete: u64, + pub maxEmbedDownloadSize: u64, + } + + #[derive(Debug, Deserialize, Serialize)] + #[allow(non_snake_case)] + + pub struct Channel { + pub maxPins: u64, + pub maxTopic: u64, + pub maxWebhooks: u64, + } + + #[derive(Debug, Deserialize, Serialize)] + pub struct Rate { + pub enabled: bool, + pub ip: Window, + pub global: Window, + pub error: Window, + pub routes: Routes, + } + + #[derive(Debug, Deserialize, Serialize)] + pub struct Window { + pub count: u64, + pub window: u64, + } + + #[derive(Debug, Deserialize, Serialize)] + pub struct Routes { + pub guild: Window, + pub webhook: Window, + pub channel: Window, + pub auth: AuthRoutes, + } + + #[derive(Debug, Deserialize, Serialize)] + #[allow(non_snake_case)] + + pub struct AuthRoutes { + pub login: Window, + pub register: Window, + } + + #[derive(Debug, Deserialize, Serialize)] + #[allow(non_snake_case)] + + pub struct AbsoluteRate { + pub register: AbsoluteWindow, + pub sendMessage: AbsoluteWindow, + } + + #[derive(Debug, Deserialize, Serialize)] + pub struct AbsoluteWindow { + pub limit: u64, + pub window: u64, + pub enabled: bool, + } + + #[derive(Debug, Deserialize, Serialize)] + #[allow(non_snake_case)] + + pub struct Config { + pub user: User, + pub guild: Guild, + pub message: Message, + pub channel: Channel, + pub rate: Rate, + pub absoluteRate: AbsoluteRate, + } +} diff --git a/src/api/policies/instance/mod.rs b/src/api/policies/instance/mod.rs new file mode 100644 index 0000000..e695695 --- /dev/null +++ b/src/api/policies/instance/mod.rs @@ -0,0 +1,5 @@ +// src/api/policies/instance/mod.rs + +pub mod limits; + +pub use limits::*; diff --git a/src/api/policies/mod.rs b/src/api/policies/mod.rs new file mode 100644 index 0000000..6b4a5bc --- /dev/null +++ b/src/api/policies/mod.rs @@ -0,0 +1,3 @@ +pub mod instance; + +pub use instance::limits::*;