pub mod message;
pub mod notion;
pub mod request;
use strum::{Display, EnumString, IntoStaticStr};
#[derive(Clone)]
pub enum Event {
Message(Box<message::MessageEvent>),
Notion(Box<notion::NotionEvent>),
Request(Box<request::RequestEvent>),
}
#[cfg(feature = "event")]
impl std::fmt::Debug for Event {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Event::Message(message_event) => f.debug_tuple("Message").field(message_event).finish(),
Event::Notion(notion_event) => f.debug_tuple("Notion").field(notion_event).finish(),
Event::Request(request_event) => f.debug_tuple("Request").field(request_event).finish(),
}
}
}
impl Event {
pub fn is_message(&self) -> bool {
matches!(self, Event::Message(..))
}
}
#[derive(Debug, Clone, EnumString, Display, IntoStaticStr)]
pub enum EventType {
#[strum(serialize = "message")]
Message,
#[strum(serialize = "notice")]
Notice,
#[strum(serialize = "request")]
Request,
#[strum(serialize = "unknown")]
Unknown,
}
pub trait EventBase: Send + Sync {
type ContactType;
type SenderType;
fn time(&self) -> u64;
fn event(&self) -> &str;
fn event_id(&self) -> &str;
fn sub_event(&self) -> &str;
fn self_id(&self) -> &str;
fn user_id(&self) -> &str;
fn contact(&self) -> Self::ContactType;
fn sender(&self) -> Self::SenderType;
}