diff --git a/src/types/utils/snowflake.rs b/src/types/utils/snowflake.rs index a9f572b..b4e1d9e 100644 --- a/src/types/utils/snowflake.rs +++ b/src/types/utils/snowflake.rs @@ -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 From for Snowflake +where + T: Into, +{ + fn from(item: T) -> Self { + Self(item.into()) + } +} + impl serde::Serialize for Snowflake { fn serialize(&self, serializer: S) -> Result where