From ffcdba0e1d689dc413a8ca139c3547f1878a226d Mon Sep 17 00:00:00 2001 From: Hirrolot Date: Fri, 8 Apr 2022 00:18:13 +0600 Subject: [PATCH] Deprecate `HandlerFactory` and `HandlerExt::dispatch_by` --- CHANGELOG.md | 4 ++++ src/dispatching/handler_ext.rs | 11 +++++++---- src/dispatching/handler_factory.rs | 1 + src/dispatching/mod.rs | 1 + 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37775159..12774217 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Rename `BotCommand` trait to `BotCommands` [**BC**]. - `BotCommands::descriptions` now returns `CommandDescriptions` instead of `String` [**BC**]. +### Deprecated + + - `HandlerFactory` and `HandlerExt::dispatch_by` in favour of `teloxide::handler!`. + ## 0.7.2 - 2022-03-23 ### Added diff --git a/src/dispatching/handler_ext.rs b/src/dispatching/handler_ext.rs index e2285cbe..694e791d 100644 --- a/src/dispatching/handler_ext.rs +++ b/src/dispatching/handler_ext.rs @@ -1,15 +1,15 @@ use std::sync::Arc; use crate::{ - dispatching::{ - dialogue::{Dialogue, GetChatId, Storage}, - HandlerFactory, - }, + dispatching::dialogue::{Dialogue, GetChatId, Storage}, types::{Me, Message}, utils::command::BotCommands, }; use dptree::{di::DependencyMap, Handler}; +#[allow(deprecated)] +use crate::dispatching::HandlerFactory; + use std::fmt::Debug; /// Extension methods for working with `dptree` handlers. @@ -51,6 +51,8 @@ pub trait HandlerExt { Upd: GetChatId + Clone + Send + Sync + 'static; #[must_use] + #[deprecated(note = "Use the teloxide::handler! API")] + #[allow(deprecated)] fn dispatch_by(self) -> Self where F: HandlerFactory; @@ -92,6 +94,7 @@ where })) } + #[allow(deprecated)] fn dispatch_by(self) -> Self where F: HandlerFactory, diff --git a/src/dispatching/handler_factory.rs b/src/dispatching/handler_factory.rs index b561fea8..53b65016 100644 --- a/src/dispatching/handler_factory.rs +++ b/src/dispatching/handler_factory.rs @@ -1,6 +1,7 @@ use dptree::{di::DependencyMap, Handler}; /// Something that can construct a handler. +#[deprecated(note = "Use the teloxide::handler! API")] pub trait HandlerFactory { type Out; diff --git a/src/dispatching/mod.rs b/src/dispatching/mod.rs index d7bb794a..33e02393 100644 --- a/src/dispatching/mod.rs +++ b/src/dispatching/mod.rs @@ -110,4 +110,5 @@ pub use crate::utils::shutdown_token::{IdleShutdownError, ShutdownToken}; pub use dispatcher::{Dispatcher, DispatcherBuilder, UpdateHandler}; pub use filter_ext::{MessageFilterExt, UpdateFilterExt}; pub use handler_ext::HandlerExt; +#[allow(deprecated)] pub use handler_factory::HandlerFactory;