pub mod id;
pub use id::EntryId;
use crate::{safe_slice::SafeSliceUntilExt, sinks::message::Message};
use std::fmt::Debug;
#[derive(PartialEq, Eq, Clone, Default, bon::Builder)]
pub struct Entry {
#[builder(required, default, setters(
name = id_internal,
vis = "",
))]
pub id: Option<EntryId>,
pub reply_to: Option<EntryId>,
pub raw_contents: Option<String>,
#[builder(into, default)]
pub msg: Message,
}
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",
&self
.raw_contents
.as_ref()
.map(|s| s.pretty_slice_until(250)),
)
.field("msg", &self.msg)
.finish()
}
}
impl<S: entry_builder::State> EntryBuilder<S> {
pub fn id(self, entry_id: String) -> EntryBuilder<entry_builder::SetId<S>>
where
S::Id: entry_builder::IsUnset,
{
self.id_internal(EntryId::new(entry_id))
}
pub fn id_raw(self, entry_id: EntryId) -> EntryBuilder<entry_builder::SetId<S>>
where
S::Id: entry_builder::IsUnset,
{
self.id_internal(Some(entry_id))
}
}