Documentation
e-utils-0.4.12 has been yanked.

📄 中文 | 📄 English

Test Status Book API API

⚡ what this ?

This is a universal feature library that integrates convenient features

🛠️ Support Features

📖 Example

[dependencies]
e-utils = {version="0.4", feature=["algorithm","cmd","dialog"]}

🔢 About Dialog example

fn main() {
  e_utils::dialog::sync::warn("Title", "test");
  e_utils::dialog::sync::folders();
  e_utils::dialog::sync::files();
}

🔢 About algorithm example

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

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

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

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

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

💡!important:

🚀 fast running

# 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

📖 License

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

See LICENSE-MIT, and COPYRIGHT for details.