Thanks to visit codestin.com
Credit goes to github.com

Skip to content

noble-gase/kr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

氪-Kr

crates.io MIT

[氪-Kr] Rust开发工具包

安装

cargo add kr --features macros

kr-core

功能

  • AES
    • CBC
    • ECB
    • GCM
  • Hash
  • 时间格式化
  • 基于Redis的分布式锁
  • 基于 bb8 的Redis异步Manager
  • API Code 宏定义:define_ok!define_error_codes!

⚠️ aes 相关功能依赖 openssl

kr-macros

派生宏:Model

  • 使用
#[derive(Model)]
#[partial(UserLite !(email, phone))] // 排除字段
#[partial(UserBrief (id, name), derive(Copy, Debug))] // 包含字段
pub struct User {
    pub id: i64,

    #[sqlx(rename = "username")]
    pub name: String,

    pub email: String,
    pub phone: String,
    pub created_at: String,
    pub updated_at: String,
}
  • 生成代码
#[derive(sqlx::FromRow)]
pub struct UserLite {
    pub id: i64,

    #[sqlx(rename = "username")]
    pub name: String,

    pub created_at: String,
    pub updated_at: String,
}

#[derive(sqlx::FromRow, Copy, Debug)]
pub struct UserBrief {
    pub id: i64,

    #[sqlx(rename = "username")]
    pub name: String,
}

👉 具体使用可以参考 rnx

Enjoy 😊

About

[氪-Kr] Rust开发工具包

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages