mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-24 15:49:27 +01:00
Various style fixes
* Removed type bounds from struct declaration * Simplified <S as Storage<D>>::Error to S::Error * Simplified complex type to BoxFuture
This commit is contained in:
parent
fff1e55a58
commit
f9b3a4836e
1 changed files with 8 additions and 17 deletions
|
@ -5,9 +5,9 @@ use crate::dispatching::{
|
||||||
},
|
},
|
||||||
DispatcherHandler, DispatcherHandlerCx,
|
DispatcherHandler, DispatcherHandlerCx,
|
||||||
};
|
};
|
||||||
use std::{convert::Infallible, future::Future, marker::PhantomData, pin::Pin};
|
use std::{convert::Infallible, marker::PhantomData};
|
||||||
|
|
||||||
use futures::StreamExt;
|
use futures::{future::BoxFuture, StreamExt};
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
|
|
||||||
use lockfree::map::Map;
|
use lockfree::map::Map;
|
||||||
|
@ -23,10 +23,7 @@ use std::sync::{Arc, Mutex};
|
||||||
///
|
///
|
||||||
/// [`Dispatcher`]: crate::dispatching::Dispatcher
|
/// [`Dispatcher`]: crate::dispatching::Dispatcher
|
||||||
/// [`DispatcherHandler`]: crate::dispatching::DispatcherHandler
|
/// [`DispatcherHandler`]: crate::dispatching::DispatcherHandler
|
||||||
pub struct DialogueDispatcher<D, S, H, Upd>
|
pub struct DialogueDispatcher<D, S, H, Upd> {
|
||||||
where
|
|
||||||
S: Storage<D> + Send + Sync + 'static,
|
|
||||||
{
|
|
||||||
storage: Arc<S>,
|
storage: Arc<S>,
|
||||||
handler: Arc<H>,
|
handler: Arc<H>,
|
||||||
_phantom: PhantomData<Mutex<D>>,
|
_phantom: PhantomData<Mutex<D>>,
|
||||||
|
@ -63,14 +60,11 @@ where
|
||||||
|
|
||||||
impl<D, S, H, Upd> DialogueDispatcher<D, S, H, Upd>
|
impl<D, S, H, Upd> DialogueDispatcher<D, S, H, Upd>
|
||||||
where
|
where
|
||||||
H: DialogueDispatcherHandler<Upd, D, <S as Storage<D>>::Error>
|
H: DialogueDispatcherHandler<Upd, D, S::Error> + Send + Sync + 'static,
|
||||||
+ Send
|
|
||||||
+ Sync
|
|
||||||
+ 'static,
|
|
||||||
Upd: GetChatId + Send + 'static,
|
Upd: GetChatId + Send + 'static,
|
||||||
D: Default + Send + 'static,
|
D: Default + Send + 'static,
|
||||||
S: Storage<D> + Send + Sync + 'static,
|
S: Storage<D> + Send + Sync + 'static,
|
||||||
<S as Storage<D>>::Error: Send + 'static,
|
S::Error: Send + 'static,
|
||||||
{
|
{
|
||||||
/// Creates a dispatcher with the specified `handler` and `storage`.
|
/// Creates a dispatcher with the specified `handler` and `storage`.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
@ -142,19 +136,16 @@ where
|
||||||
|
|
||||||
impl<D, S, H, Upd> DispatcherHandler<Upd> for DialogueDispatcher<D, S, H, Upd>
|
impl<D, S, H, Upd> DispatcherHandler<Upd> for DialogueDispatcher<D, S, H, Upd>
|
||||||
where
|
where
|
||||||
H: DialogueDispatcherHandler<Upd, D, <S as Storage<D>>::Error>
|
H: DialogueDispatcherHandler<Upd, D, S::Error> + Send + Sync + 'static,
|
||||||
+ Send
|
|
||||||
+ Sync
|
|
||||||
+ 'static,
|
|
||||||
Upd: GetChatId + Send + 'static,
|
Upd: GetChatId + Send + 'static,
|
||||||
D: Default + Send + 'static,
|
D: Default + Send + 'static,
|
||||||
S: Storage<D> + Send + Sync + 'static,
|
S: Storage<D> + Send + Sync + 'static,
|
||||||
<S as Storage<D>>::Error: Send + 'static,
|
S::Error: Send + 'static,
|
||||||
{
|
{
|
||||||
fn handle(
|
fn handle(
|
||||||
self,
|
self,
|
||||||
updates: mpsc::UnboundedReceiver<DispatcherHandlerCx<Upd>>,
|
updates: mpsc::UnboundedReceiver<DispatcherHandlerCx<Upd>>,
|
||||||
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static>>
|
) -> BoxFuture<'static, ()>
|
||||||
where
|
where
|
||||||
DispatcherHandlerCx<Upd>: 'static,
|
DispatcherHandlerCx<Upd>: 'static,
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue