From aa8c20d501b58001a5e1b24964c62363e2112ff8 Mon Sep 17 00:00:00 2001 From: benj Date: Fri, 25 Nov 2022 16:42:16 -0800 Subject: some shell is coming together and a rough API --- src/util/mod.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/util/mod.rs (limited to 'src/util') diff --git a/src/util/mod.rs b/src/util/mod.rs new file mode 100644 index 0000000..c939b95 --- /dev/null +++ b/src/util/mod.rs @@ -0,0 +1,15 @@ +use log::error; +use rand::distributions::Alphanumeric; +use rand::{thread_rng, Rng}; + +pub fn log_err(e: sqlx::Error) -> sqlx::Error { + error!("{:?}", e); + e +} +pub fn generate_random_url_safe(n: usize) -> String { + thread_rng() + .sample_iter(&Alphanumeric) + .take(n) + .map(char::from) + .collect() +} -- cgit v1.2.3