diff --git a/Cargo.lock b/Cargo.lock index 7d70c8d1cc7..9c04d09cc8d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1123,7 +1123,6 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" name = "poise" version = "0.6.1" dependencies = [ - "async-trait", "derivative", "env_logger", "fluent", diff --git a/Cargo.toml b/Cargo.toml index 3489806e412..8cd1bacefae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,6 @@ repository = "https://github.com/serenity-rs/poise/" tokio = { version = "1.25.1", default-features = false } # for async in general futures-util = { version = "0.3.13", default-features = false } # for async in general poise_macros = { path = "macros", version = "0.6.1" } # remember to update the version on changes! -async-trait = { version = "0.1.48", default-features = false } # various traits regex = { version = "1.6.0", default-features = false, features = ["std"] } # prefix tracing = { version = "0.1.40", features = ["log"] } # warning about weird state derivative = "2.2.0" diff --git a/src/argument.rs b/src/argument.rs index 443286bacb1..b4eb831e185 100644 --- a/src/argument.rs +++ b/src/argument.rs @@ -9,7 +9,6 @@ use crate::{ /// This is useful if you need to take an argument via a string, but immediately convert it via [`FromStr`]. pub struct StrArg(pub T); -#[async_trait::async_trait] impl SlashArgument for StrArg where T: FromStr, @@ -40,7 +39,6 @@ where } } -#[async_trait::async_trait] impl<'a, T> PopArgument<'a> for StrArg where T: FromStr, diff --git a/src/choice_parameter.rs b/src/choice_parameter.rs index a625c6723ae..b2c6c62a49d 100644 --- a/src/choice_parameter.rs +++ b/src/choice_parameter.rs @@ -22,7 +22,6 @@ pub trait ChoiceParameter: Sized { fn localized_name(&self, locale: &str) -> Option<&'static str>; } -#[async_trait::async_trait] impl crate::SlashArgument for T { async fn extract( _: &serenity::Context, @@ -55,7 +54,6 @@ impl crate::SlashArgument for T { } } -#[async_trait::async_trait] impl<'a, T: ChoiceParameter> crate::PopArgument<'a> for T { async fn pop_from( args: &'a str, diff --git a/src/lib.rs b/src/lib.rs index c7d4de4b595..a268d03436b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -411,9 +411,6 @@ pub mod samples { pub use crate::builtins::*; } -#[doc(hidden)] -pub use {async_trait::async_trait, futures_util}; - /// This module re-exports a bunch of items from all over serenity. Useful if you can't /// remember the full paths of serenity items. /// diff --git a/src/modal.rs b/src/modal.rs index d1edeb69f8e..599e9c4f490 100644 --- a/src/modal.rs +++ b/src/modal.rs @@ -1,5 +1,7 @@ //! Modal trait and utility items for implementing it (mainly for the derive macro) +use std::future::Future; + use crate::serenity_prelude as serenity; /// Meant for use in derived [`Modal::parse`] implementation @@ -40,10 +42,7 @@ pub fn find_modal_text( /// Underlying code for the modal spawning convenience function which abstracts over the kind of /// interaction -async fn execute_modal_generic< - M: Modal, - F: std::future::Future>, ->( +async fn execute_modal_generic>>( ctx: &serenity::Context, create_interaction_response: impl FnOnce(serenity::CreateInteractionResponse) -> F, modal_custom_id: String, @@ -169,7 +168,6 @@ pub async fn execute_modal_on_component_interaction( /// Ok(()) /// } /// ``` -#[async_trait::async_trait] pub trait Modal: Sized { /// Returns an interaction response builder which creates the modal for this type /// @@ -187,18 +185,24 @@ pub trait Modal: Sized { /// /// For a variant that is triggered on component interactions, see [`execute_modal_on_component_interaction`]. // TODO: add execute_with_defaults? Or add a `defaults: Option` param? - async fn execute( + fn execute( ctx: crate::ApplicationContext<'_, U, E>, - ) -> Result, serenity::Error> { - execute_modal(ctx, None::, None).await + ) -> impl Future, serenity::Error>> + Send + where + Self: Send, + { + execute_modal(ctx, None::, None) } /// Calls `execute_modal(ctx, Some(defaults), None)`. See [`execute_modal`] // TODO: deprecate this in favor of execute_modal()? - async fn execute_with_defaults( + fn execute_with_defaults( ctx: crate::ApplicationContext<'_, U, E>, defaults: Self, - ) -> Result, serenity::Error> { - execute_modal(ctx, Some(defaults), None).await + ) -> impl Future, serenity::Error>> + Send + where + Self: Send, + { + execute_modal(ctx, Some(defaults), None) } } diff --git a/src/prefix_argument/argument_trait.rs b/src/prefix_argument/argument_trait.rs index 0ca690c2166..baec1f2bef6 100644 --- a/src/prefix_argument/argument_trait.rs +++ b/src/prefix_argument/argument_trait.rs @@ -19,20 +19,18 @@ pub(crate) type PopArgumentResult<'a, T> = /// does. This is for consistency's sake and also because it keeps open the possibility of parsing whitespace. /// /// Similar in spirit to [`std::str::FromStr`]. -#[async_trait::async_trait] pub trait PopArgument<'a>: Sized { /// Pops an argument from the `args` string. /// /// See the documentation of [`PopArgumentResult`] for the return type. - async fn pop_from( + fn pop_from( args: &'a str, attachment_index: usize, ctx: &serenity::Context, msg: &serenity::Message, - ) -> PopArgumentResult<'a, Self>; + ) -> impl std::future::Future>; } -#[async_trait::async_trait] impl<'a> PopArgument<'a> for String { async fn pop_from( args: &'a str, @@ -47,7 +45,6 @@ impl<'a> PopArgument<'a> for String { } } -#[async_trait::async_trait] impl<'a> PopArgument<'a> for bool { async fn pop_from( args: &'a str, @@ -68,7 +65,6 @@ impl<'a> PopArgument<'a> for bool { } } -#[async_trait::async_trait] impl<'a> PopArgument<'a> for serenity::Attachment { async fn pop_from( args: &'a str, @@ -108,7 +104,6 @@ where /// Implements PopArgument for many types via `[pop_from_via_argumentconvert`]. macro_rules! impl_popargument_via_argumentconvert { ($($type:ty),*) => {$( - #[async_trait::async_trait] impl<'a> PopArgument<'a> for $type { async fn pop_from( args: &'a str, diff --git a/src/prefix_argument/code_block.rs b/src/prefix_argument/code_block.rs index 53bf4d7ebaf..dce319f7051 100644 --- a/src/prefix_argument/code_block.rs +++ b/src/prefix_argument/code_block.rs @@ -109,7 +109,6 @@ fn pop_from(args: &str) -> Result<(&str, CodeBlock), CodeBlockError> { } } -#[async_trait::async_trait] impl<'a> PopArgument<'a> for CodeBlock { /// Parse a single-line or multi-line code block. The output of `Self::code` should mirror what /// the official Discord client renders, and the output of `Self::language` should mirror the diff --git a/src/prefix_argument/key_value_args.rs b/src/prefix_argument/key_value_args.rs index 7069098fe76..470f29d8594 100644 --- a/src/prefix_argument/key_value_args.rs +++ b/src/prefix_argument/key_value_args.rs @@ -71,7 +71,6 @@ impl KeyValueArgs { } } -#[async_trait::async_trait] impl<'a> PopArgument<'a> for KeyValueArgs { async fn pop_from( args: &'a str, diff --git a/src/slash_argument/slash_trait.rs b/src/slash_argument/slash_trait.rs index 5eb60fda5e3..64f4322bacb 100644 --- a/src/slash_argument/slash_trait.rs +++ b/src/slash_argument/slash_trait.rs @@ -8,14 +8,13 @@ use crate::serenity::json::*; use crate::{serenity_prelude as serenity, CowVec}; /// Implement this trait on types that you want to use as a slash command parameter. -#[async_trait::async_trait] pub trait SlashArgument: Sized { /// Extract a Rust value of type T from the slash command argument, given via a [`serenity::ResolvedValue`]. - async fn extract( + fn extract( ctx: &serenity::Context, interaction: &serenity::CommandInteraction, value: &serenity::ResolvedValue<'_>, - ) -> Result; + ) -> impl std::future::Future>; /// Create a slash command parameter equivalent to type T. /// @@ -64,7 +63,6 @@ where /// Implements `SlashArgument` via `serenity::ArgumentConvert` macro_rules! impl_for_argumentconvert { ($type:ty) => { - #[async_trait::async_trait] impl SlashArgument for $type { async fn extract( ctx: &serenity::Context, @@ -86,7 +84,6 @@ impl_for_argumentconvert!(serenity::Message); /// Implements slash argument trait for integer types macro_rules! impl_for_integer { ($($t:ty)*) => { $( - #[async_trait::async_trait] impl SlashArgument for $t { async fn extract( _: &serenity::Context, @@ -120,7 +117,6 @@ impl_for_integer!(i8 i16 i32 i64 isize u8 u16 u32 u64 usize); /// Versatile macro to implement `SlashArgument` for simple types macro_rules! impl_slash_argument { ($type:ty, |$ctx:pat, $interaction:pat, $slash_param_type:ident ( $($arg:pat),* )| $extractor:expr) => { - #[async_trait::async_trait] impl SlashArgument for $type { async fn extract( $ctx: &serenity::Context,