mycommon-utils 0.1.2

Common utilities library for database operations, Redis caching and system utilities
Documentation
// use lazy_static::lazy_static;

use uuid::Uuid;

pub struct GeneratorId;

impl GeneratorId {
    pub fn uuid_v4() -> String {
        Uuid::new_v4().as_simple().to_string()
    }

    //生成一个12位的唯一字符串
    pub fn uuid_v4_12() -> String {
        let uuid = Uuid::new_v4().to_string().replace("-","");
        uuid[0..12].to_string()
    }
    //生成雪花id
    pub fn snowflake_id() -> i64 {
        snowflake::SnowflakeIdBucket::new(1,1).get_id()
    }

}

// lazy_static! {
//     static ref UUID_GENERATOR: UuidGenerator = UuidGenerator;
// }