# e-utils
**Repository Path**: eternalnight996/e-utils
## Basic Information
- **Project Name**: e-utils
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2024-10-28
- **Last Updated**: 2025-04-21
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
e-utils
这是一个集成了多种便捷功能的通用特性库
[](https://github.com/eternalnight996/e-utils)[](https://docs.rs/e-utils)[](LICENSE)
[English](README.md) | 简体中文
### 🛠️ 支持的功能
APP |
Windows 10 |
Unix |
Macos |
描述 |
| fs_ext |
√ |
x |
x |
[锁定共享、锁定访问、自定义标志2、属性2、安全质量标志2] |
| Dialog |
√ |
√ |
√ |
跨平台对话框功能 |
| Base64 |
√ |
√ |
√ |
Base64 编码和解码 |
| Algorithm |
√ |
√ |
√ |
随机数生成、nanoid 和其他算法 |
| Image |
√ |
√ |
√ |
图像处理功能 |
| cmd |
√ |
√ |
√ |
命令行操作和管理 |
| encode |
√ |
√ |
√ |
编码转换和自动解码 |
| http |
√ |
√ |
√ |
HTTP 请求功能 |
| regex |
√ |
√ |
√ |
正则表达式支持 |
| _ |
× |
× |
× |
未实现或保留功能 |
# 📖 示例
```toml
[dependencies]
e-utils = {version="0.4", feature=["algorithm","cmd","dialog"]}
```
#### 🔢 About Dialog example
```rust
fn main() {
e_utils::dialog::sync::warn("Title", "test");
e_utils::dialog::sync::folders();
e_utils::dialog::sync::files();
}
```
#### 🔢 About algorithm example
```rust
use e_utils::algorithm;
fn main() {
// 生成随机布尔值
let random_bool = algorithm!();
println!("随机布尔值: {}", random_bool);
// 生成随机 u32
let random_u32: u32 = algorithm!(#u32);
println!("随机 u32: {}", random_u32);
// 生成随机数组
let random_array: [u8; 5] = algorithm!([u8; 5]);
println!("随机数组: {:?}", random_array);
// 生成随机 RGB 颜色
let rgb = algorithm!(rgb 0, 255);
println!("随机 RGB: {:?}", rgb);
// 生成默认长度(21)的 nanoid
let default_nanoid = algorithm!(nanoid);
println!("默认 nanoid: {}", default_nanoid);
// 生成自定义长度的 nanoid
let custom_nanoid = algorithm!(nanoid 10);
println!("自定义 nanoid: {}", custom_nanoid);
// 生成指定范围内的随机数
let random_range = algorithm!(0..100);
println!("随机数 (0-99): {}", random_range);
// 生成负数范围内的随机数
let negative_range = algorithm!((-50)..50);
println!("随机数 (-50 到 49): {}", negative_range);
// 生成自定义字母表的 nanoid
let custom_alphabet_nanoid = algorithm!(nanoid 8, &"abcdef123456".chars().collect::>());
println!("自定义字母表 nanoid: {}", custom_alphabet_nanoid);
// 使用不安全模式生成 nanoid
let unsafe_nanoid = algorithm!(nanoid unsafe 15);
println!("不安全模式 nanoid: {}", unsafe_nanoid);
// 使用不安全模式和自定义字母表生成 nanoid
let unsafe_custom_nanoid = algorithm!(nanoid unsafe 12, &"ABCDEFGHIJKLMNOPQRSTUVWXYZ".chars().collect::>());
println!("不安全模式自定义字母表 nanoid: {}", unsafe_custom_nanoid);
}
```
#### 🔢 About encode example
```rust
use e_utils::system::encode::auto_decode;
fn main() -> Result<(), Box> {
let bytes = vec![0xE4, 0xBD, 0xA0, 0xE5, 0xA5, 0xBD]; // "你好" in UTF-8
let decoded = auto_decode(&bytes)?;
assert_eq!(decoded, "你好");
Ok(())
}
```
#### 🔢 About Cmd example
```rust
use e_utils::{shell_open, Cmd};
fn test_cmd() {
let output = Cmd::new("echo Hello from cmd").output().unwrap();
assert_eq!(output.stdout, "Hello from cmd");
assert!(Cmd::new("echo Hello from cmd")
.output()
.is_err());
}
fn test_shell_open_windows() {
assert!(shell_open("C:\\").is_ok());
}
fn main() {
test_cmd();
test_shell_open_windows();
}
```
#### 🔢 About ACmd example
```rust
use e_utils::{a_shell_open, Cmd};
async fn test_cmd() {
let output = Cmd::new("echo Hello from cmd").a_output().await.unwrap();
assert_eq!(output.stdout, "Hello from cmd");
assert!(Cmd::new("echo Hello from cmd")
.output()
.is_err());
}
async fn test_shell_open_windows() {
assert!(a_shell_open("C:\\").await.is_ok());
}
#[tokio::main]
async fn main() {
test_cmd().await;
test_shell_open_windows().await;
}
```
#### 🔢 About Cmd tasks example
```rust
use std::time::Duration;
use e_utils::{tasks::sync::CmdManage, Cmd};
fn test_performance() {
use std::time::Instant;
let cmd_manage = CmdManage::new(8);
for _ in 0..1000 {
cmd_manage
.add_cmd(Cmd::new("echo").arg("Performance test"))
.unwrap();
}
let start = Instant::now();
cmd_manage.run().unwrap();
let duration = start.elapsed();
println!("Time taken to run 1000 commands: {:?}", duration);
assert!(
duration < Duration::from_secs(10),
"Performance test took too long"
);
}
fn main() {
test_performance();
}
```
# ✨ Features
```toml
```
## `💡!重要:`
```text
```
# 🚀 快速运行
```sh
# Donwloading the object
git clone https://github.com/eternalnight996/e-utils
cd e-utils
# test all object support
cargo test
# The benchmark results will help you understand the performance characteristics of e-utils in different scenarios.
cargo bench
```
## 📊 性能基准
---
## 🦊 已运用项目
## 🔭 为什么需要这个库?
---
## 🙋 参考项目与资料
- [Rust 官方文档](https://www.rust-lang.org/documentation.html)
- [Serde 文档](https://serde.rs/)
- [Cargo 用户指南](https://doc.rust-lang.org/cargo/)
- [e-utils 仓库](https://github.com/eternalnight996/e-utils)
## 📜 开源协议
本项目采用 [MIT](LICENSE-MIT) 和 [Apache 2.0](LICENSE-APACHE) 双重协议。
---
Built with ❤️ by eternalnight996 and contributors.