aboutsummaryrefslogtreecommitdiff
path: root/crates/secd/src/util/mod.rs
blob: da16901a33e7b3ba579a8ccac7e6fcd109798bee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use log::error;
use rand::distributions::Alphanumeric;
use rand::{thread_rng, Rng};

use crate::SecdError;

pub(crate) fn log_err(e: Box<dyn std::error::Error>, new_e: SecdError) -> SecdError {
    error!("{:?}", e);
    new_e
}
pub(crate) fn log_err_sqlx(e: sqlx::Error) -> sqlx::Error {
    error!("{:?}", e);
    e
}
pub(crate) fn generate_random_url_safe(n: usize) -> String {
    thread_rng()
        .sample_iter(&Alphanumeric)
        .take(n)
        .map(char::from)
        .collect()
}