teloxide-fork 0.20.0

An elegant Telegram bots framework for Rust
Documentation
use serde::{Deserialize, Serialize};
use teloxide_core::types::{BusinessConnectionId, ChatId};

/// Identifies a dialogue in an ordinary chat or in a particular business
/// connection.
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct DialogueKey {
    pub chat_id: ChatId,
    pub business_connection_id: Option<BusinessConnectionId>,
}

impl From<ChatId> for DialogueKey {
    fn from(chat_id: ChatId) -> Self {
        Self { chat_id, business_connection_id: None }
    }
}

impl DialogueKey {
    /// Identifies a dialogue within a business connection.
    #[must_use]
    pub fn business(chat_id: ChatId, business_connection_id: BusinessConnectionId) -> Self {
        Self { chat_id, business_connection_id: Some(business_connection_id) }
    }
}