1pub mod authorization;
2pub mod error;
3pub mod service;
4pub mod utils;
5pub mod http;
6pub type GenericResult<T> = Result<T, String>;
7#[cfg(target_family = "unix")]
8pub async fn random(buff: &mut [u8]) -> Result<usize, std::io::Error> {
9 use tokio::io::AsyncReadExt;
10
11 let mut fd = tokio::fs::OpenOptions::new()
12 .read(true)
13 .open("/dev/urandom")
14 .await?;
15 let ret = fd.read_exact(buff).await?;
16 Ok(ret)
17}
18#[macro_export]
19macro_rules! random_str {
20 ($need_size:expr) => {
21 {
22 let mut buff=[0u8;$need_size];
23 let _=crate::random(&mut buff).await;
24 hex::encode(buff)
25 }
26 };
27}