https://github.com/noble-gase/kr
[氪-Kr] Rust开发工具包
https://github.com/noble-gase/kr
aes hash redlock redlock-redis time
Last synced: 5 months ago
JSON representation
[氪-Kr] Rust开发工具包
- Host: GitHub
- URL: https://github.com/noble-gase/kr
- Owner: noble-gase
- License: mit
- Created: 2025-03-11T01:50:49.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-11-10T02:11:58.000Z (7 months ago)
- Last Synced: 2025-11-10T02:22:50.099Z (7 months ago)
- Topics: aes, hash, redlock, redlock-redis, time
- Language: Rust
- Homepage: https://crates.io/crates/kr
- Size: 63.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 氪-Kr
[
](https://crates.io/crates/kr)
[
](http://opensource.org/licenses/MIT)
[氪-Kr] Rust开发工具包
## 安装
```shell
cargo add kr --features macros
```
## kr-core
#### 功能
- AES
- CBC
- ECB
- GCM
- Hash
- 时间格式化
- 基于Redis的分布式锁
- 基于 `bb8` 的Redis异步Manager
⚠️ `aes` 相关功能依赖 `openssl`
## kr-macros
#### 派生宏:Model
- 使用
```rust
#[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,
}
```
- 生成代码
```rust
#[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](https://crates.io/crates/rnx)
**Enjoy 😊**