carapax 0.36.0

A Telegram Bot Framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use serde::{Serialize, de::DeserializeOwned};

const SESSION_KEY_PREFIX: &str = "__carapax_dialogue";

/// Represents a state of dialogue.
pub trait DialogueState: Default + DeserializeOwned + Serialize {
    /// Returns a unique name for the dialogue.
    fn dialogue_name() -> &'static str;

    /// Returns a key for the dialogue state in a session.
    fn session_key() -> String {
        format!("{}:{}", SESSION_KEY_PREFIX, Self::dialogue_name())
    }
}