Get last possible Msg id

This commit is contained in:
Joscha 2022-07-19 17:04:44 +02:00
parent 2beb44a17c
commit d638ba2887
4 changed files with 15 additions and 0 deletions

View file

@ -284,6 +284,11 @@ pub struct SessionView {
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)]
pub struct Snowflake(pub u64);
impl Snowflake {
pub const MIN: Self = Snowflake(u64::MIN);
pub const MAX: Self = Snowflake(u64::MAX);
}
impl Serialize for Snowflake {
fn serialize<S: ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
// Convert u64 to base36 string

View file

@ -49,6 +49,10 @@ impl Msg for LogMsg {
fn content(&self) -> Styled {
Styled::new(&self.content)
}
fn last_possible_id() -> Self::Id {
Self::Id::MAX
}
}
#[derive(Debug, Clone)]

View file

@ -14,6 +14,8 @@ pub trait Msg {
fn time(&self) -> DateTime<Utc>;
fn nick(&self) -> Styled;
fn content(&self) -> Styled;
fn last_possible_id() -> Self::Id;
}
#[derive(PartialEq, Eq, PartialOrd, Ord)]

View file

@ -70,6 +70,10 @@ impl Msg for EuphMsg {
fn content(&self) -> Styled {
self.content.trim().into()
}
fn last_possible_id() -> Self::Id {
Snowflake::MAX
}
}
impl From<EuphRequest> for Request {