Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrasnitski committed Jan 30, 2025
1 parent 0aa231d commit d11db36
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 62 deletions.
47 changes: 29 additions & 18 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,32 @@ edition = "2021"
rust-version = "1.82"

[dependencies]
# Serenity workspace crates
serenity-core = { path = "./serenity-core" }

# Required dependencies
serde_json = "1.0.108"
async-trait = "0.1.74"
tracing = { version = "0.1.40", features = ["log"] }
futures = { version = "0.3.29", default-features = false, features = ["std"] }
serde = { version = "1.0.192", features = ["derive", "rc"] }
url = { version = "2.4.1", features = ["serde"] }
serde_json = "1.0.108"
tokio = { version = "1.34.0", features = ["macros", "rt", "sync", "time", "io-util"] }
futures = { version = "0.3.29", default-features = false, features = ["std"] }
small-fixed-array = { version = "0.4", features = ["serde"] }
strum = { version = "0.26", features = ["derive"] }
to-arraystring = "0.2.0"
extract_map = { version = "0.1.0", features = ["serde", "iter_mut"] }
aformat = "0.1.3"

# Optional dependencies
aformat = { version = "0.1.3", optional = true }
ed25519-dalek = { version = "2.0.0", optional = true }
extract_map = { version = "0.1.0", features = ["serde", "iter_mut"], optional = true }
flate2 = { version = "1.0.28", optional = true }
zstd-safe = { version = "7.2.1", optional = true }
reqwest = { version = "0.12.2", default-features = false, features = ["multipart", "stream", "json"], optional = true }
tokio-tungstenite = { version = "0.24.0", features = ["url"], optional = true }
mini-moka = { version = "0.10.2", optional = true }
parking_lot = { version = "0.12.1"}
ed25519-dalek = { version = "2.0.0", optional = true }
reqwest = { version = "0.12.2", default-features = false, optional = true }
small-fixed-array = { version = "0.4", features = ["serde"], optional = true }
strum = { version = "0.26", features = ["derive"], optional = true }
to-arraystring = { version = "0.2.0", optional = true }
tokio-tungstenite = { version = "0.24.0", features = ["url"], optional = true }
tracing = { version = "0.1.40", features = ["log"], optional = true }
typesize = { version = "0.1.6", optional = true, features = ["url", "time", "serde_json", "secrecy", "parking_lot", "nonmax", "extract_map_01"] }
# serde feature only allows for serialisation,
# Serenity workspace crates
serenity-core = { path = "./serenity-core" }
url = { version = "2.4.1", features = ["serde"], optional = true }
zstd-safe = { version = "7.2.1", optional = true }

[features]
# Defaults with different backends
Expand All @@ -75,11 +76,21 @@ builder = ["serenity-core/builder"]
cache = ["serenity-core/cache"]
# Enables collectors, a utility feature that lets you await interaction events in code with
# zero setup, without needing to setup an InteractionCreate event listener.
collector = ["gateway"]
collector = ["gateway", "to-arraystring"]
# Enables the Framework trait which is an abstraction for old-style text commands.
framework = ["gateway"]
# Enables gateway support, which allows bots to listen for Discord events.
gateway = ["model", "flate2", "reqwest"]
gateway = [
"model",
"aformat",
"extract_map",
"flate2",
"reqwest",
"small-fixed-array",
"strum",
"tracing",
"url"
]
# Enables HTTP, which enables bots to execute actions on Discord.
http = ["serenity-core/http"]
# Enables wrapper methods around HTTP requests on model types.
Expand Down
47 changes: 23 additions & 24 deletions serenity-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,49 +12,48 @@ rust-version.workspace = true


[dependencies]
serenity-voice-model = { version = "0.2.0", path = "../voice-model", optional = true }

aformat = "0.1.3"
arrayvec = { version = "0.7.4", features = ["serde"] }
base64 = "0.22.0"
bitflags = "2.4.2"
base64 = { version = "0.22.0" }
serde_json = "1.0.108"
serde = { version = "1.0.192", features = ["derive", "rc"] }
bool_to_bitflags = "0.1.2"
extract_map = { version = "0.1.0", features = ["serde", "iter_mut"] }
nonmax = { version = "0.5.5", features = ["serde"] }
parking_lot = { version = "0.12.1"}
serde = { version = "1.0.192", features = ["derive", "rc"] }
serde_cow = "0.1.0"
serde_json = "1.0.108"
small-fixed-array = { version = "0.4", features = ["serde"] }
strum = { version = "0.26", features = ["derive"] }
time = { version = "0.3.36", features = ["formatting", "parsing", "serde-well-known"] }
to-arraystring = "0.2.0"
tokio = { version = "1.34.0", features = ["macros", "rt", "sync", "time", "io-util"] }
zeroize = { version = "1.7" } # Not used in serenity, but bumps the minimal version from secrecy
time = { version = "0.3.36", features = ["formatting", "parsing", "serde-well-known"] }
strum = { version = "0.26", features = ["derive"] }
tracing = { version = "0.1.40", features = ["log"] }
url = { version = "2.4.1", features = ["serde"] }
zeroize = { version = "1.7" }

bytes = { version = "1.5.0", optional = true }
fxhash = { version = "0.2.1", optional = true }
chrono = { version = "0.4.31", default-features = false, features = ["clock", "serde"], optional = true }
dashmap = { version = "6.1.0", features = ["serde"], optional = true }
futures = { version = "0.3.29", default-features = false, features = ["std"], optional = true }
mime_guess = { version = "2.0.4", optional = true }
percent-encoding = { version = "2.3.0", optional = true }
small-fixed-array = { version = "0.4", features = ["serde"] }
bool_to_bitflags = { version = "0.1.2" }
futures = { version = "0.3.29", default-features = false, features = ["std"] }
reqwest = { version = "0.12.2", default-features = false, features = ["multipart", "stream", "json"], optional = true }
tokio-tungstenite = { version = "0.21.0", optional = true }
reqwest = { version = "0.12.2", default-features = false, features = ["multipart", "json"], optional = true }
typesize = { version = "0.1.6", optional = true, features = ["url", "time", "serde_json", "secrecy", "parking_lot", "nonmax", "extract_map_01"] }
extract_map = { version = "0.1.0", features = ["serde", "iter_mut"] }
serde_cow = { version = "0.1.0" }
aformat = "0.1.3"
arrayvec = { version = "0.7.4", features = ["serde"] }
url = { version = "2.4.1", features = ["serde"] }
bytes = "1.5.0"
parking_lot = { version = "0.12.1"}
mini-moka = { version = "0.10.2", optional = true }
tracing = { version = "0.1.40", features = ["log"] }
serenity-voice-model = { version = "0.2.0", path = "../voice-model", optional = true }

[dev-dependencies.http_crate]
version = "1.1.0"
package = "http"

[features]
default = ["cache", "chrono", "model", "rustls_backend"]

builder = ["tokio/fs"]
builder = ["tokio/fs", "bytes"]
cache = ["fxhash", "dashmap"]
http = ["dashmap", "mime_guess", "percent-encoding"]
model = ["builder", "http", "utils"]
model = ["builder", "http", "utils", "futures"]
utils = []
chrono = ["dep:chrono", "typesize?/chrono"]
typesize = ["dep:typesize", "dashmap/typesize", "small-fixed-array/typesize", "bool_to_bitflags/typesize"]
Expand Down
4 changes: 3 additions & 1 deletion serenity-core/src/internal/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ pub use super::utils::join_to_string;
#[cfg(feature = "http")]
pub use crate::error::Error;
pub use crate::error::Result;
pub use crate::secrets::{SecretString, Token};
pub use crate::secrets::SecretString;
#[cfg(feature = "http")]
pub use crate::secrets::Token;

pub type JsonMap = serde_json::Map<String, Value>;
2 changes: 2 additions & 0 deletions src/collector/quick_modal.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std::borrow::Cow;
use std::future::Future;

use to_arraystring::ToArrayString;

use crate::builder::{CreateActionRow, CreateInputText, CreateInteractionResponse, CreateModal};
use crate::collector::ModalInteractionCollector;
use crate::gateway::client::Context;
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion src/gateway/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//! [`Client`]: client::Client
pub mod client;
pub mod constants;
mod error;
pub mod sharding;
#[cfg(feature = "voice")]
Expand All @@ -23,12 +24,12 @@ use reqwest::IntoUrl;
use reqwest::Url;
use serde::de::{Deserialize, Deserializer, Error as DeError};

use self::constants::Opcode;
pub use self::error::Error as GatewayError;
pub use self::sharding::*;
#[cfg(feature = "voice")]
pub use self::voice::VoiceGatewayManager;
pub use self::ws::WsClient;
use crate::constants::Opcode;
use crate::error::CoreError;
use crate::internal::prelude::*;
use crate::model::gateway::{Activity, ActivityType};
Expand Down
2 changes: 1 addition & 1 deletion src/gateway/sharding/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ pub use self::shard_manager::{
pub use self::shard_messenger::ShardMessenger;
pub use self::shard_queuer::{ShardQueue, ShardQueuer, ShardQueuerMessage};
pub use self::shard_runner::{ShardRunner, ShardRunnerMessage, ShardRunnerOptions};
use super::constants::{self, CloseCode};
use super::{ActivityData, ChunkGuildFilter, GatewayError, GatewayEvent, PresenceData, WsClient};
use crate::constants::{self, CloseCode};
use crate::error::CoreError;
use crate::internal::prelude::*;
use crate::model::event::Event;
Expand Down
2 changes: 1 addition & 1 deletion src/gateway/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use url::Url;
#[cfg(feature = "transport_compression_zstd")]
use zstd_safe::{DStream as ZstdInflater, InBuffer, OutBuffer};

use super::constants::{self, Opcode};
use super::{
ActivityData,
ChunkGuildFilter,
Expand All @@ -26,7 +27,6 @@ use super::{
PresenceData,
TransportCompression,
};
use crate::constants::{self, Opcode};
use crate::error::CoreError;
use crate::model::gateway::{GatewayIntents, ShardInfo};
use crate::model::id::{GuildId, UserId};
Expand Down
4 changes: 2 additions & 2 deletions src/internal.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#[cfg(feature = "gateway")]
pub mod prelude {
pub use serde_json::Value;
pub use serenity_core::secrets::Token;
pub use small_fixed_array::{FixedArray, FixedString, TruncatingInto};
pub use to_arraystring::ToArrayString;

pub use crate::error::{Error, Result};

pub type JsonMap = serde_json::Map<String, Value>;
}

#[cfg(feature = "gateway")]
pub mod tokio {
use std::future::Future;

Expand Down
25 changes: 11 additions & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,30 +85,29 @@ extern crate serde;
#[macro_use]
mod internal;

pub mod constants;
pub use serenity_core::model;
pub mod prelude;

#[cfg(feature = "builder")]
pub use serenity_core::builder;
#[cfg(feature = "cache")]
pub use serenity_core::cache;
#[cfg(feature = "collector")]
pub mod collector;
#[cfg(feature = "framework")]
pub mod framework;
#[cfg(feature = "gateway")]
pub mod gateway;
#[cfg(feature = "http")]
pub use serenity_core::http;
#[cfg(feature = "interactions_endpoint")]
pub mod interactions_endpoint;
pub use serenity_core::secrets;
#[cfg(feature = "utils")]
pub use serenity_core::utils;

mod error;

#[cfg(feature = "builder")]
pub use serenity_core::builder;
#[cfg(feature = "cache")]
pub use serenity_core::cache;
#[cfg(feature = "http")]
pub use serenity_core::http;
#[cfg(feature = "utils")]
pub use serenity_core::utils;
pub use serenity_core::{model, secrets};

pub use crate::error::{Error, Result};
#[cfg(feature = "gateway")]
pub use crate::gateway::client::Client;
Expand All @@ -126,14 +125,12 @@ pub mod all {
#[cfg(feature = "collector")]
#[doc(no_inline)]
pub use crate::collector::*;
#[doc(no_inline)]
pub use crate::constants::*;
#[cfg(feature = "framework")]
#[doc(no_inline)]
pub use crate::framework::*;
#[cfg(feature = "gateway")]
#[doc(no_inline)]
pub use crate::gateway::{client::*, *};
pub use crate::gateway::{client::*, constants::*, *};
#[cfg(feature = "http")]
#[doc(no_inline)]
pub use crate::http::*;
Expand Down

0 comments on commit d11db36

Please sign in to comment.