diff --git a/src/id.rs b/src/id.rs index fe0b9eb..91bb2fd 100644 --- a/src/id.rs +++ b/src/id.rs @@ -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 { + Ok(Id(try_log!( + Uuid::parse_str(input), + "Unable to parse Uuid from str: {}", + input + ))) + } } impl fmt::Display for Id {