Documentation
<img src="public/ico/white_64x64.ico" alt="e-utils"/>

### 📄 [中文]docs/README.zh.md  | 📄  [English]README.md

[![Test Status](https://github.com/rust-random/rand/workflows/Tests/badge.svg?event=push)](https://github.com/eternalnight996/e-utils/actions) [![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://doc.rust-lang.org/book/) [![API](https://img.shields.io/badge/api-master-yellow.svg)](https://github.com/eternalnight996/e-utils) [![API](https://docs.rs/e-utils/badge.svg)](https://docs.rs/rand)

# ⚡ what this ?

**This is a universal feature library that integrates convenient features**

### 🛠️ Support Features

<table style="background:#000">
  <tr>
    <th><h3 style="color:#fff">APP</h3></th>
    <th><h3 style="color:#fff">Windows 10</h3></th>
    <th><h3 style="color:#fff">Unix</h3></th>
    <th><h3 style="color:#fff">Macos</h3></th>
    <th><h3 style="color:#fff">Description</h3></th>
  </tr>
  <tr>
    <td>fs_ext</td>
    <td><h4 style="color:green"></h4></td>
    <td><h4 style="color:red">x</h4></td>
    <td><h4 style="color:red">x</h4></td>
    <td><span style="color:#ccc">[lock_share, lock_access, custom_flags2, attributes2, security_qos_flags2]</span></td>
  </tr>
  <tr>
    <td>Dialog</td>
    <td><h4 style="color:green"></h4></td>
    <td><h4 style="color:green"></h4></td>
    <td><h4 style="color:green"></h4></td>
    <td><span style="color:#ccc">Cross-platform dialog functionality</span></td>
  </tr>
  <tr>
    <td>Base64</td>
    <td><h4 style="color:green"></h4></td>
    <td><h4 style="color:green"></h4></td>
    <td><h4 style="color:green"></h4></td>
    <td><span style="color:#ccc">Base64 encoding and decoding</span></td>
  </tr>
  <tr>
    <td>Algorithm</td>
    <td><h4 style="color:green"></h4></td>
    <td><h4 style="color:green"></h4></td>
    <td><h4 style="color:green"></h4></td>
    <td><span style="color:#ccc">Random number generation, nanoid, and other algorithms</span></td>
  </tr>
  <tr>
    <td>Image</td>
    <td><h4 style="color:green"></h4></td>
    <td><h4 style="color:green"></h4></td>
    <td><h4 style="color:green"></h4></td>
    <td><span style="color:#ccc">Image processing functionality</span></td>
  </tr>
  <tr>
    <td>cmd</td>
    <td><h4 style="color:green"></h4></td>
    <td><h4 style="color:green"></h4></td>
    <td><h4 style="color:green"></h4></td>
    <td><span style="color:#ccc">Command line operations and management</span></td>
  </tr>
  <tr>
    <td>encode</td>
    <td><h4 style="color:green"></h4></td>
    <td><h4 style="color:green"></h4></td>
    <td><h4 style="color:green"></h4></td>
    <td><span style="color:#ccc">Encoding conversion and automatic decoding</span></td>
  </tr>
  <tr>
    <td>http</td>
    <td><h4 style="color:green"></h4></td>
    <td><h4 style="color:green"></h4></td>
    <td><h4 style="color:green"></h4></td>
    <td><span style="color:#ccc">HTTP request functionality</span></td>
  </tr>
  <tr>
    <td>regex</td>
    <td><h4 style="color:green"></h4></td>
    <td><h4 style="color:green"></h4></td>
    <td><h4 style="color:green"></h4></td>
    <td><span style="color:#ccc">Regular expression support</span></td>
  </tr>
  <tr>
    <td>_</td>
    <td><h4 style="color:red">×</h4></td>
    <td><h4 style="color:red">×</h4></td>
    <td><h4 style="color:red">×</h4></td>
    <td><span style="color:#ccc">Unimplemented or reserved functionality</span></td>
  </tr>
</table>

# 📖 Example

```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::<Vec<char>>());
  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::<Vec<char>>());
  println!("不安全模式自定义字母表 nanoid: {}", unsafe_custom_nanoid);
}
```

#### 🔢 About encode example

```rust
use e_utils::system::encode::auto_decode;
fn main() -> Result<(), Box<dyn std::error::Error>> {
  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
```

## `💡!important:`

```text
```

# 🚀 fast running

```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
```


# 📊 Performance Benchmarks


---
# 🦊 Applied Projects


---

## 🔭 Why Do You Need This Library?

---

# 🙋 Reference items and materials

- [Rust Official Documentation]https://www.rust-lang.org/documentation.html
- [Serde Documentation]https://serde.rs/
- [Cargo User Guide]https://doc.rust-lang.org/cargo/
- [e-utils Repository]https://github.com/eternalnight996/e-utils

# 📖 License


Rand is distributed under the terms of both the MIT license and the
Apache License (Version 2.0).

See [LICENSE-MIT](LICENSE-MIT), and
[COPYRIGHT](COPYRIGHT) for details.