pub(crate) mod length_limiter;
use std::fmt::Debug;
use url::Url;
#[derive(Clone, Default)]
pub struct Message {
pub title: Option<String>,
pub body: Option<String>,
pub link: Option<Url>,
pub media: Option<Vec<Media>>,
}
#[derive(Clone, Copy, Debug)]
pub struct MessageId(pub i64);
#[derive(Clone)]
pub enum Media {
Photo(Url),
Video(Url),
}
impl Message {
#[must_use]
pub fn is_empty(&self) -> bool {
self.title.is_none() && self.body.is_none() && self.link.is_none() && self.media.is_none()
}
}
impl From<i64> for MessageId {
fn from(value: i64) -> Self {
Self(value)
}
}
impl Debug for Message {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Message")
.field("title", &self.title)
.field("body", &self.body)
.field("link", &self.link.as_ref().map(Url::as_str))
.field("media", &self.media)
.finish()
}
}
impl Debug for Media {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Photo(x) => f.debug_tuple("Photo").field(&x.as_str()).finish(),
Self::Video(x) => f.debug_tuple("Video").field(&x.as_str()).finish(),
}
}
}