|
|
|
@ -1,3 +1,7 @@
|
|
|
|
|
//! Universally unique identifier
|
|
|
|
|
//!
|
|
|
|
|
//! Wrapper around `Uuid` to store it as text in sql table.
|
|
|
|
|
|
|
|
|
|
use std::cmp::{Eq, PartialEq};
|
|
|
|
|
use std::fmt;
|
|
|
|
|
use std::hash::{Hash, Hasher};
|
|
|
|
@ -6,10 +10,12 @@ use rusqlite::types::{FromSql, FromSqlError, FromSqlResult, ToSql, ToSqlOutput,
|
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
use uuid::Uuid;
|
|
|
|
|
|
|
|
|
|
/// Universally unique identifier
|
|
|
|
|
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
|
|
|
|
pub struct Id(Uuid);
|
|
|
|
|
|
|
|
|
|
impl Id {
|
|
|
|
|
/// Return a newly generated `Id`
|
|
|
|
|
pub fn new() -> Self {
|
|
|
|
|
Self(Uuid::new_v4())
|
|
|
|
|
}
|
|
|
|
|