diff --git a/src/dispatching/private/dispatcher.rs b/src/dispatching/private/dispatcher.rs index 4174e5cc..41925056 100644 --- a/src/dispatching/private/dispatcher.rs +++ b/src/dispatching/private/dispatcher.rs @@ -4,8 +4,8 @@ use crate::{ types::{ChatKind, Update, UpdateKind}, }; -pub struct Dispatcher<'a, S, H> { - storage: Box + 'a>, +pub struct Dispatcher<'a, Session, H> { + storage: Box + 'a>, handler: H, } @@ -28,10 +28,10 @@ mod macros { } } -impl<'a, S, H> Dispatcher<'a, S, H> +impl<'a, Session, H> Dispatcher<'a, Session, H> where - S: Default + 'a, - H: Handler, + Session: Default + 'a, + H: Handler, { pub fn new(handler: H) -> Self { Self { @@ -42,7 +42,7 @@ where pub fn with_storage(handler: H, storage: Stg) -> Self where - Stg: Storage + 'a, + Stg: Storage + 'a, { Self { storage: Box::new(storage), diff --git a/src/dispatching/private/storage/in_mem_storage.rs b/src/dispatching/private/storage/in_mem_storage.rs index 539a227b..c379453f 100644 --- a/src/dispatching/private/storage/in_mem_storage.rs +++ b/src/dispatching/private/storage/in_mem_storage.rs @@ -4,20 +4,22 @@ use super::Storage; use std::collections::HashMap; #[derive(Clone, Debug, Eq, PartialEq, Default)] -pub struct InMemStorage { - map: HashMap, +pub struct InMemStorage { + map: HashMap, } #[async_trait(?Send)] #[async_trait] -impl Storage for InMemStorage { - type Session = S; - - async fn remove_session(&mut self, chat_id: i64) -> Option { +impl Storage for InMemStorage { + async fn remove_session(&mut self, chat_id: i64) -> Option { self.map.remove(&chat_id) } - async fn update_session(&mut self, chat_id: i64, state: S) -> Option { + async fn update_session( + &mut self, + chat_id: i64, + state: Session, + ) -> Option { self.map.insert(chat_id, state) } } diff --git a/src/dispatching/private/storage/mod.rs b/src/dispatching/private/storage/mod.rs index 8c5936ff..161f8f2a 100644 --- a/src/dispatching/private/storage/mod.rs +++ b/src/dispatching/private/storage/mod.rs @@ -5,13 +5,11 @@ pub use in_mem_storage::InMemStorage; #[async_trait(?Send)] #[async_trait] -pub trait Storage { - type Session; - - async fn remove_session(&mut self, chat_id: i64) -> Option; +pub trait Storage { + async fn remove_session(&mut self, chat_id: i64) -> Option; async fn update_session( &mut self, chat_id: i64, - state: Self::Session, - ) -> Option; + state: Session, + ) -> Option; }