31 releases

new 0.4.6 Dec 11, 2024
0.3.74 Aug 28, 2024
0.3.53 Jul 31, 2024
0.1.20 Aug 13, 2022

#81 in Development tools

Download history 180/week @ 2024-08-23 18/week @ 2024-08-30 3/week @ 2024-09-06 171/week @ 2024-09-13 107/week @ 2024-09-20 51/week @ 2024-09-27 5/week @ 2024-10-04 2/week @ 2024-10-11 45/week @ 2024-11-01 19/week @ 2024-11-08 2/week @ 2024-11-15 2/week @ 2024-11-22 1019/week @ 2024-12-06

1,023 downloads per month
Used in 6 crates

Custom license

295KB
6.5K SLoC

e-utils

📄 中文 | 📄 English

Test Status Book API API

⚡ what this ?

This is a universal feature library that integrates convenient features

🛠️ Support Features

APP

Windows 10

Unix

Macos

Description

fs_ext

x

x

[lock_share, lock_access, custom_flags2, attributes2, security_qos_flags2]
Dialog

Cross-platform dialog functionality
Base64

Base64 encoding and decoding
Algorithm

Random number generation, nanoid, and other algorithms
Image

Image processing functionality
cmd

Command line operations and management
encode

Encoding conversion and automatic decoding
http

HTTP request functionality
regex

Regular expression support
_

×

×

×

Unimplemented or reserved functionality

📖 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.

Dependencies

~0.4–18MB
~277K SLoC