utils: migrate to jirachi for generating unique keys

Signed-off-by: ATechnoHazard <amolele@gmail.com>
This commit is contained in:
Amogh Lele 2020-07-05 22:28:34 +05:30
parent 2b785d3fe4
commit 62c5d88048
No known key found for this signature in database
GPG Key ID: F475143EDEDEBA3C
3 changed files with 16 additions and 17 deletions

12
Cargo.lock generated
View File

@ -605,6 +605,17 @@ version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6"
[[package]]
name = "jirachi"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d4dcf06f952eef788e3a08fae6c2937c8d729c7abe152b503f7474d97c6899f"
dependencies = [
"anyhow",
"diesel",
"dotenv",
]
[[package]] [[package]]
name = "js-sys" name = "js-sys"
version = "0.3.40" version = "0.3.40"
@ -638,6 +649,7 @@ dependencies = [
"diesel", "diesel",
"diesel_migrations", "diesel_migrations",
"dotenv", "dotenv",
"jirachi",
"jsonwebtoken", "jsonwebtoken",
"rocket", "rocket",
"rocket_contrib", "rocket_contrib",

View File

@ -24,6 +24,7 @@ slog-async = "2.5.0"
bcrypt = "0.8.0" bcrypt = "0.8.0"
chrono = "0.4.11" chrono = "0.4.11"
uuid = { version = "0.8.1", features = ["serde", "v4"] } uuid = { version = "0.8.1", features = ["serde", "v4"] }
jirachi = "0.1.1"
[profile.release] [profile.release]
lto = "fat" lto = "fat"

View File

@ -1,20 +1,6 @@
use uuid::Uuid; use jirachi::Jirachi;
// const VOWELS: Vec<&str> = vec!["a", "e", "i", "o", "u", "y"];
// const CONSONANTS: Vec<&str> = vec!["b", "c", "d", "f", "g", "h", "l", "m", "n", "p", "r", "s", "t", "v", "w"];
// const UNCOMMON_CON: Vec<&str> = vec!["x", "z", "q", "j", "k"];
// const COMMON_VOW_VOW_ST: Vec<&str> = vec!["ea", "ai", "a", "yu"];
// const COMMON_VOW_VOW: Vec<&str> = vec!["ee", "oo", "ea", "ai", "ay", "uy"];
// const COMMON_VOW_CON: Vec<&str> = vec!["in", "an", "ing", "im", "er", "ex", "un", "est", "ux", "am", "ap"];
// const COMMON_VOW_CON_ST: Vec<&str> = vec!["un", "im", "in", "ex"];
// const COMMON_CON_VOW: Vec<&str> = vec!["me", "li", "le", "ly", "pe", "re", "fi", "nu", "co", "lo", "cu", "ki", "cy", "fu", "mo", "bi"];
// const COMMON_CON_VOW_ST: Vec<&str> = vec!["me", "li", "fu", "pe", "lo", "mo"];
// const COMMON_CON_CON_ST: Vec<&str> = vec!["gh", "th", "gr", "st", "ph", "pr", "t", "cr"];
// const COMMON_CON_CON: Vec<&str> = vec!["ll", "pp", "gh", "th", "gr", "ng", "st", "ph", "rr", "gn", "ck", "rf", "tt", "cr"];
//
// const CONSONANT: i8 = 1;
// const VOWEL: i8 = 0;
pub fn get_random_id() -> String { pub fn get_random_id() -> String {
Uuid::new_v4().to_string() let mut jirachi = Jirachi::new().unwrap();
jirachi.wish().unwrap()
} }