Get last possible Msg id
This commit is contained in:
parent
2beb44a17c
commit
d638ba2887
4 changed files with 15 additions and 0 deletions
|
|
@ -284,6 +284,11 @@ pub struct SessionView {
|
||||||
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
pub struct Snowflake(pub u64);
|
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 {
|
impl Serialize for Snowflake {
|
||||||
fn serialize<S: ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
fn serialize<S: ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
||||||
// Convert u64 to base36 string
|
// Convert u64 to base36 string
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,10 @@ impl Msg for LogMsg {
|
||||||
fn content(&self) -> Styled {
|
fn content(&self) -> Styled {
|
||||||
Styled::new(&self.content)
|
Styled::new(&self.content)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn last_possible_id() -> Self::Id {
|
||||||
|
Self::Id::MAX
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ pub trait Msg {
|
||||||
fn time(&self) -> DateTime<Utc>;
|
fn time(&self) -> DateTime<Utc>;
|
||||||
fn nick(&self) -> Styled;
|
fn nick(&self) -> Styled;
|
||||||
fn content(&self) -> Styled;
|
fn content(&self) -> Styled;
|
||||||
|
|
||||||
|
fn last_possible_id() -> Self::Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(PartialEq, Eq, PartialOrd, Ord)]
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,10 @@ impl Msg for EuphMsg {
|
||||||
fn content(&self) -> Styled {
|
fn content(&self) -> Styled {
|
||||||
self.content.trim().into()
|
self.content.trim().into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn last_possible_id() -> Self::Id {
|
||||||
|
Snowflake::MAX
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<EuphRequest> for Request {
|
impl From<EuphRequest> for Request {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue