mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-23 15:01:45 +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.
|
/// Implementors of this trait are treated as error-handlers.
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait ErrorPolicy {
|
pub trait ErrorPolicy<E> {
|
||||||
type Error;
|
async fn handle_error(&mut self, error: E);
|
||||||
|
|
||||||
async fn handle_error(&mut self, error: Self::Error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A convenient structure with an error-handling closure. Implements
|
/// A convenient structure with an error-handling closure. Implements
|
||||||
|
@ -15,14 +13,12 @@ pub trait ErrorPolicy {
|
||||||
pub struct FnErrorPolicy<F>(pub F);
|
pub struct FnErrorPolicy<F>(pub F);
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<E, F, Fut> ErrorPolicy<Error = E> for FnErrorPolicy<F>
|
impl<E, F, Fut> ErrorPolicy<E> for FnErrorPolicy<F>
|
||||||
where
|
where
|
||||||
F: FnMut(E) -> Fut + Send,
|
F: FnMut(E) -> Fut + Send,
|
||||||
Fut: Future<Output = ()>,
|
Fut: Future<Output = ()>,
|
||||||
E: Send,
|
E: Send,
|
||||||
{
|
{
|
||||||
type Error = E;
|
|
||||||
|
|
||||||
async fn handle_error(&mut self, error: E) {
|
async fn handle_error(&mut self, error: E) {
|
||||||
self.0(error);
|
self.0(error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ pub struct FilterDispatcher<'a, E, Ep> {
|
||||||
|
|
||||||
impl<'a, E, Ep> FilterDispatcher<'a, E, Ep>
|
impl<'a, E, Ep> FilterDispatcher<'a, E, Ep>
|
||||||
where
|
where
|
||||||
Ep: ErrorPolicy<Error = E>,
|
Ep: ErrorPolicy<E>,
|
||||||
E: std::fmt::Debug, // TODO: Is this really necessary?
|
E: std::fmt::Debug, // TODO: Is this really necessary?
|
||||||
{
|
{
|
||||||
pub fn new(error_policy: Ep) -> Self {
|
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
|
where
|
||||||
E: std::fmt::Debug,
|
E: std::fmt::Debug,
|
||||||
U: Updater + 'a,
|
U: Updater + 'a,
|
||||||
Ep: ErrorPolicy<Error = E>,
|
Ep: ErrorPolicy<E>,
|
||||||
{
|
{
|
||||||
async fn dispatch(&'a mut self, updater: U) {
|
async fn dispatch(&'a mut self, updater: U) {
|
||||||
FilterDispatcher::dispatch(self, updater).await
|
FilterDispatcher::dispatch(self, updater).await
|
||||||
|
|
Loading…
Reference in a new issue