|
|
|
@ -10,6 +10,9 @@ use rusqlite::types::{FromSql, FromSqlError, FromSqlResult, ToSql, ToSqlOutput,
|
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
use uuid::Uuid;
|
|
|
|
|
|
|
|
|
|
use crate::result::RudeResult;
|
|
|
|
|
use crate::try_log;
|
|
|
|
|
|
|
|
|
|
/// Universally unique identifier
|
|
|
|
|
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
|
|
|
|
pub struct Id(Uuid);
|
|
|
|
@ -19,6 +22,14 @@ impl Id {
|
|
|
|
|
pub fn new() -> Self {
|
|
|
|
|
Self(Uuid::new_v4())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn parse_str(input: &str) -> RudeResult<Self> {
|
|
|
|
|
Ok(Id(try_log!(
|
|
|
|
|
Uuid::parse_str(input),
|
|
|
|
|
"Unable to parse Uuid from str: {}",
|
|
|
|
|
input
|
|
|
|
|
)))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl fmt::Display for Id {
|
|
|
|
|