Struct teloxide::dispatching::dialogue::InMemStorage
source · pub struct InMemStorage<D> { /* private fields */ }
Expand description
A dialogue storage based on std::collections::HashMap
.
Note
All your dialogues will be lost after you restart your bot. If you need to
store them somewhere on a drive, you should use e.g.
super::SqliteStorage
or implement your own.
Implementations§
source§impl<S> InMemStorage<S>
impl<S> InMemStorage<S>
sourcepub fn new() -> Arc<Self> ⓘ
pub fn new() -> Arc<Self> ⓘ
Examples found in repository?
examples/purchase.rs (line 54)
47 48 49 50 51 52 53 54 55 56 57 58 59
async fn main() {
pretty_env_logger::init();
log::info!("Starting purchase bot...");
let bot = Bot::from_env();
Dispatcher::builder(bot, schema())
.dependencies(dptree::deps![InMemStorage::<State>::new()])
.enable_ctrlc_handler()
.build()
.dispatch()
.await;
}
More examples
examples/dialogue.rs (line 53)
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
async fn main() {
pretty_env_logger::init();
log::info!("Starting dialogue bot...");
let bot = Bot::from_env();
Dispatcher::builder(
bot,
Update::filter_message()
.enter_dialogue::<Message, InMemStorage<State>, State>()
.branch(dptree::case![State::Start].endpoint(start))
.branch(dptree::case![State::ReceiveFullName].endpoint(receive_full_name))
.branch(dptree::case![State::ReceiveAge { full_name }].endpoint(receive_age))
.branch(
dptree::case![State::ReceiveLocation { full_name, age }].endpoint(receive_location),
),
)
.dependencies(dptree::deps![InMemStorage::<State>::new()])
.enable_ctrlc_handler()
.build()
.dispatch()
.await;
}
Trait Implementations§
source§impl<D: Debug> Debug for InMemStorage<D>
impl<D: Debug> Debug for InMemStorage<D>
source§impl<D> Storage<D> for InMemStorage<D>where
D: Clone + Send + 'static,
impl<D> Storage<D> for InMemStorage<D>where D: Clone + Send + 'static,
type Error = InMemStorageError
source§fn remove_dialogue(
self: Arc<Self>,
chat_id: ChatId
) -> BoxFuture<'static, Result<(), Self::Error>>where
D: Send + 'static,
fn remove_dialogue( self: Arc<Self>, chat_id: ChatId ) -> BoxFuture<'static, Result<(), Self::Error>>where D: Send + 'static,
Removes a dialogue indexed by
chat_id
. Read more