From bf6c4bd75168671a5a0e53f7390ebd4796a6bd57 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Sun, 14 Mar 2021 15:39:00 +0100 Subject: chore: add helpers module --- src/helpers.rs | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/helpers.rs (limited to 'src/helpers.rs') diff --git a/src/helpers.rs b/src/helpers.rs new file mode 100644 index 0000000..d915a50 --- /dev/null +++ b/src/helpers.rs @@ -0,0 +1,9 @@ +use uuid::Uuid; + +/// Returns a valid Uuid if `id` is not a valid Uuid +pub fn uuid_from_string(id: &String) -> Uuid { + return match Uuid::parse_str(&id) { + Ok(x) => x, + Err(_) => Uuid::parse_str("00000000000000000000000000000000").unwrap(), + }; +} -- cgit v1.2.3-18-g5258