Deprecate HandlerFactory and HandlerExt::dispatch_by

This commit is contained in:
Hirrolot 2022-04-08 00:18:13 +06:00
parent 4530f935cb
commit ffcdba0e1d
4 changed files with 13 additions and 4 deletions

View file

@ -26,6 +26,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Rename `BotCommand` trait to `BotCommands` [**BC**]. - Rename `BotCommand` trait to `BotCommands` [**BC**].
- `BotCommands::descriptions` now returns `CommandDescriptions` instead of `String` [**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 ## 0.7.2 - 2022-03-23
### Added ### Added

View file

@ -1,15 +1,15 @@
use std::sync::Arc; use std::sync::Arc;
use crate::{ use crate::{
dispatching::{ dispatching::dialogue::{Dialogue, GetChatId, Storage},
dialogue::{Dialogue, GetChatId, Storage},
HandlerFactory,
},
types::{Me, Message}, types::{Me, Message},
utils::command::BotCommands, utils::command::BotCommands,
}; };
use dptree::{di::DependencyMap, Handler}; use dptree::{di::DependencyMap, Handler};
#[allow(deprecated)]
use crate::dispatching::HandlerFactory;
use std::fmt::Debug; use std::fmt::Debug;
/// Extension methods for working with `dptree` handlers. /// Extension methods for working with `dptree` handlers.
@ -51,6 +51,8 @@ pub trait HandlerExt<Output> {
Upd: GetChatId + Clone + Send + Sync + 'static; Upd: GetChatId + Clone + Send + Sync + 'static;
#[must_use] #[must_use]
#[deprecated(note = "Use the teloxide::handler! API")]
#[allow(deprecated)]
fn dispatch_by<F>(self) -> Self fn dispatch_by<F>(self) -> Self
where where
F: HandlerFactory<Out = Output>; F: HandlerFactory<Out = Output>;
@ -92,6 +94,7 @@ where
})) }))
} }
#[allow(deprecated)]
fn dispatch_by<F>(self) -> Self fn dispatch_by<F>(self) -> Self
where where
F: HandlerFactory<Out = Output>, F: HandlerFactory<Out = Output>,

View file

@ -1,6 +1,7 @@
use dptree::{di::DependencyMap, Handler}; use dptree::{di::DependencyMap, Handler};
/// Something that can construct a handler. /// Something that can construct a handler.
#[deprecated(note = "Use the teloxide::handler! API")]
pub trait HandlerFactory { pub trait HandlerFactory {
type Out; type Out;

View file

@ -110,4 +110,5 @@ pub use crate::utils::shutdown_token::{IdleShutdownError, ShutdownToken};
pub use dispatcher::{Dispatcher, DispatcherBuilder, UpdateHandler}; pub use dispatcher::{Dispatcher, DispatcherBuilder, UpdateHandler};
pub use filter_ext::{MessageFilterExt, UpdateFilterExt}; pub use filter_ext::{MessageFilterExt, UpdateFilterExt};
pub use handler_ext::HandlerExt; pub use handler_ext::HandlerExt;
#[allow(deprecated)]
pub use handler_factory::HandlerFactory; pub use handler_factory::HandlerFactory;