aboutsummaryrefslogtreecommitdiff
path: root/src/util/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/mod.rs')
-rw-r--r--src/util/mod.rs15
1 files changed, 15 insertions, 0 deletions
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()
+}