use crate::sink::message::Message;
use std::{fmt::Debug, ops::Deref};
#[derive(PartialEq, Eq, Clone, Hash, Debug)]
pub struct EntryId(pub String);
#[derive(Clone, Default)]
pub struct Entry {
pub id: Option<EntryId>,
pub reply_to: Option<EntryId>,
pub raw_contents: Option<String>,
pub msg: Message,
}
impl Deref for EntryId {
type Target = str;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<String> for EntryId {
fn from(value: String) -> Self {
Self(value)
}
}
impl From<&str> for EntryId {
fn from(value: &str) -> Self {
Self(value.to_owned())
}
}
impl Debug for Entry {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Entry")
.field("id", &self.id)
.field("reply_to", &self.reply_to)
.field("raw_contents.is_some()", &self.raw_contents.is_some())
.field("msg", &self.msg)
.finish()
}
}