mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-23 06:51:01 +01:00
Fix
This commit is contained in:
parent
65e003120d
commit
1d9c42c309
2 changed files with 5 additions and 9 deletions
|
@ -4,10 +4,8 @@ use async_trait::async_trait;
|
|||
|
||||
/// Implementors of this trait are treated as error-handlers.
|
||||
#[async_trait]
|
||||
pub trait ErrorPolicy {
|
||||
type Error;
|
||||
|
||||
async fn handle_error(&mut self, error: Self::Error);
|
||||
pub trait ErrorPolicy<E> {
|
||||
async fn handle_error(&mut self, error: E);
|
||||
}
|
||||
|
||||
/// A convenient structure with an error-handling closure. Implements
|
||||
|
@ -15,14 +13,12 @@ pub trait ErrorPolicy {
|
|||
pub struct FnErrorPolicy<F>(pub F);
|
||||
|
||||
#[async_trait]
|
||||
impl<E, F, Fut> ErrorPolicy<Error = E> for FnErrorPolicy<F>
|
||||
impl<E, F, Fut> ErrorPolicy<E> for FnErrorPolicy<F>
|
||||
where
|
||||
F: FnMut(E) -> Fut + Send,
|
||||
Fut: Future<Output = ()>,
|
||||
E: Send,
|
||||
{
|
||||
type Error = E;
|
||||
|
||||
async fn handle_error(&mut self, error: E) {
|
||||
self.0(error);
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ pub struct FilterDispatcher<'a, E, Ep> {
|
|||
|
||||
impl<'a, E, Ep> FilterDispatcher<'a, E, Ep>
|
||||
where
|
||||
Ep: ErrorPolicy<Error = E>,
|
||||
Ep: ErrorPolicy<E>,
|
||||
E: std::fmt::Debug, // TODO: Is this really necessary?
|
||||
{
|
||||
pub fn new(error_policy: Ep) -> Self {
|
||||
|
@ -269,7 +269,7 @@ impl<'a, U, E, Ep> Dispatcher<'a, U> for FilterDispatcher<'a, E, Ep>
|
|||
where
|
||||
E: std::fmt::Debug,
|
||||
U: Updater + 'a,
|
||||
Ep: ErrorPolicy<Error = E>,
|
||||
Ep: ErrorPolicy<E>,
|
||||
{
|
||||
async fn dispatch(&'a mut self, updater: U) {
|
||||
FilterDispatcher::dispatch(self, updater).await
|
||||
|
|
Loading…
Reference in a new issue