librarys/
lib.rs

1//! # Rust 快速开发工具类库
2//! 
3//! 这是一个全面的工具库,提供字符串处理、日期时间、文件操作、JSON处理、验证、随机数生成和加密等功能。
4//!
5//! ## 模块说明
6//!
7//! - `core`: 核心基础工具(字符串、验证、转换)
8//! - `datetime`: 日期时间工具
9//! - `io`: 输入输出工具(文件、媒体、压缩)
10//! - `crypto`: 加密解密工具(哈希、对称/非对称加密)
11//! - `data`: 数据处理工具(JSON、XML、集合)
12//! - `random`: 随机数生成工具
13//! - `network`: 网络工具(HTTP、URL、SSL)
14//! - `system`: 系统工具(设备信息、进程、内存)
15//!
16//! ## 使用示例
17//!
18//! ```rust
19//! use librarys::core::string_utils;
20//! use librarys::datetime::date_utils;
21//!
22//! // 字符串工具
23//! let result = string_utils::is_empty("");
24//! 
25//! // 日期工具
26//! let now = date_utils::current_timestamp();
27//!
28//! // 验证工具
29//! let is_valid = librarys::core::validation::is_email("test@example.com");
30//! ```
31
32// 核心模块(总是可用)
33pub mod core;
34
35#[cfg(feature = "datetime")]
36pub mod datetime;
37
38#[cfg(feature = "io")]
39pub mod io;
40
41#[cfg(any(feature = "crypto", feature = "crypto-full"))]
42pub mod crypto;
43
44#[cfg(feature = "data")]
45pub mod data;
46
47#[cfg(feature = "random")]
48pub mod random;
49
50#[cfg(feature = "network")]
51pub mod network;
52
53 // 系统模块总是可用
54pub mod system;
55
56// 为了向后兼容,重新导出原有的模块名称
57pub use core::string_utils;
58pub use core::validation;
59
60#[cfg(feature = "datetime")]
61pub use datetime::date_utils;
62
63#[cfg(feature = "io")]
64pub use io::file_utils;
65
66#[cfg(feature = "data")]
67pub use data::json_utils;
68
69#[cfg(feature = "random")]
70pub use random::generators as random_utils;
71
72#[cfg(any(feature = "crypto", feature = "crypto-full"))]
73pub use crypto::*;
74
75// 重新导出常用功能(基于特性)
76pub use core::*;
77
78#[cfg(feature = "datetime")]
79pub use datetime::*;
80
81#[cfg(feature = "io")]
82pub use io::*;
83
84#[cfg(feature = "data")]
85pub use data::*;
86
87#[cfg(feature = "random")]
88pub use random::*;
89
90/// 库版本信息
91pub const VERSION: &str = env!("CARGO_PKG_VERSION");
92
93/// 错误类型定义
94pub use anyhow::{Error, Result};
95
96#[cfg(test)]
97mod tests {
98    use super::*;
99
100    #[test]
101    fn test_version() {
102        assert!(!VERSION.is_empty());
103    }
104}