| Crates.io | baichun-framework-core |
| lib.rs | baichun-framework-core |
| version | 0.1.0 |
| created_at | 2025-06-12 11:23:46.508406+00 |
| updated_at | 2025-06-12 11:23:46.508406+00 |
| description | Core module for Baichun-Rust framework |
| homepage | |
| repository | https://github.com/baichun-framework/baichun-framework |
| max_upload_size | |
| id | 1709700 |
| size | 83,333 |
baichun-framework-core 是 Baichun Framework 的核心模块,提供了一系列基础功能和工具,用于构建企业级 Web 应用。
thiserror 和 anyhow 提供统一的错误处理机制tokio 的异步运行时serde 和 serde_json 进行数据序列化tracing 日志系统chrono 的时间工具将以下内容添加到你的 Cargo.toml 文件中:
[dependencies]
baichun-framework-core = "0.1"
use baichun_framework_core::jwt::{create_token, verify_token};
use baichun_framework_core::password::{hash_password, verify_password};
// JWT 令牌示例
let claims = Claims {
sub: "user123".to_string(),
exp: 1735689600, // 2025-01-01
};
let token = create_token(&claims, "your-secret-key")?;
let verified = verify_token(&token, "your-secret-key")?;
// 密码加密示例
let password = "my-secure-password";
let hashed = hash_password(password)?;
let is_valid = verify_password(password, &hashed)?;
full:启用所有功能(默认)jwt:启用 JWT 相关功能password:启用密码加密相关功能validation:启用数据验证功能本项目采用 MIT 许可证。详见 LICENSE 文件。