Merge pull request #582 from teloxide/deprecate-dispatch-by

Deprecate `HandlerFactory` and `HandlerExt::dispatch_by`
This commit is contained in:
Hirrolot 2022-04-10 22:53:37 +06:00 committed by GitHub
commit 5e21c4d881
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 4 deletions

View file

@ -27,6 +27,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `BotCommands::descriptions` now returns `CommandDescriptions` instead of `String` [**BC**]. - `BotCommands::descriptions` now returns `CommandDescriptions` instead of `String` [**BC**].
- Mark `Dialogue::new` as `#[must_use]`. - Mark `Dialogue::new` as `#[must_use]`.
### 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;