use { std::{ collections::HashMap, any::type_name, time::{ SystemTime, UNIX_EPOCH, }, }, urlencoding::decode as url_decode, uuid::Uuid, crate::{ html::*, }, }; #[allow(dead_code)] pub fn type_of(_: T) -> &'static str { type_name::() } pub fn uuid_v4() -> Uuid { Uuid::new_v4() } pub fn build_html(body: &str) -> String { format!("{}{}{}{}", HEADER_HTML, CSS3, body, FOOTER_HTML) } pub fn double_split(body: String, first: &str, second: &str) -> HashMap { body.split(first) .filter_map(|c| { c.split_once(second) .map(|(l, r)| ( l.trim().to_owned(), format!("{}", url_decode(r).expect("UTF-8")).trim().to_owned() )) }) .collect::>() } pub fn time() -> u32 { SystemTime::now() .duration_since(UNIX_EPOCH) .unwrap() .as_secs() as u32 } pub fn time_mcs() -> u128 { SystemTime::now() .duration_since(UNIX_EPOCH) .unwrap() .as_micros() }