polars_utils/
unique_id.rs1use uuid::Uuid;
2
3#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
5#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6#[cfg_attr(feature = "dsl-schema", derive(schemars::JsonSchema))]
7pub struct UniqueId(Uuid);
8
9impl UniqueId {
10 #[expect(clippy::new_without_default)]
11 #[inline]
12 pub fn new() -> Self {
13 Self(Uuid::new_v4())
14 }
15
16 pub fn as_u128(&self) -> u128 {
17 self.0.as_u128()
18 }
19}
20
21impl std::fmt::Display for UniqueId {
22 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23 write!(f, "{}", self.0.as_hyphenated())
24 }
25}