use serde::{Deserialize, Serialize};
use std::borrow::Cow;
use std::hash::Hasher;
mod chat;
mod content;
mod telegram;
mod update;
pub use chat::*;
pub use content::*;
pub use telegram::*;
pub use update::*;
pub(crate) fn new_fixed_hasher() -> FixedHasher {
FixedHasher(0xcbf29ce484222325)
}
pub(crate) struct FixedHasher(u64);
impl Hasher for FixedHasher {
fn finish(&self) -> u64 {
self.0
}
fn write(&mut self, bytes: &[u8]) {
for &b in bytes {
self.0 ^= b as u64;
self.0 = self.0.wrapping_mul(0x100000001b3);
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct MessageId(
pub i32,
);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct ChatId(
pub i64,
);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct UserId(
pub u64,
);
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct ScreenId(
pub Cow<'static, str>,
);
impl From<&'static str> for ScreenId {
fn from(s: &'static str) -> Self {
Self(Cow::Borrowed(s))
}
}
impl From<String> for ScreenId {
fn from(s: String) -> Self {
Self(Cow::Owned(s))
}
}
impl std::fmt::Display for ScreenId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
#[derive(Debug, Clone)]
pub struct InlineQueryResult {
pub id: String,
pub kind: InlineResultKind,
pub title: Option<String>,
pub description: Option<String>,
pub thumb_url: Option<String>,
pub message_text: Option<String>,
pub parse_mode: ParseMode,
pub keyboard: Option<crate::keyboard::InlineKeyboard>,
}
#[derive(Debug, Clone)]
pub enum InlineResultKind {
Article,
Photo {
url: String,
},
Gif {
url: String,
},
Video {
url: String,
mime: String,
},
Voice {
url: String,
},
Document {
url: String,
mime: String,
},
}