Minor snowflake updates (#179)
* Make snowflake fully public * Simple into for snowflake
This commit is contained in:
parent
2d7fe96eda
commit
1801d22273
|
@ -17,7 +17,7 @@ const EPOCH: i64 = 1420070400000;
|
|||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
#[cfg_attr(feature = "sqlx", derive(Type))]
|
||||
#[cfg_attr(feature = "sqlx", sqlx(transparent))]
|
||||
pub struct Snowflake(u64);
|
||||
pub struct Snowflake(pub u64);
|
||||
|
||||
impl Snowflake {
|
||||
/// Generates a snowflake for the current timestamp, with worker id 0 and process id 1.
|
||||
|
@ -53,6 +53,15 @@ impl Display for Snowflake {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> From<T> for Snowflake
|
||||
where
|
||||
T: Into<u64>,
|
||||
{
|
||||
fn from(item: T) -> Self {
|
||||
Self(item.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl serde::Serialize for Snowflake {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
|
|
Loading…
Reference in New Issue