e-utils

Crates.ioe-utils
lib.rse-utils
version0.4.6
sourcesrc
created_at2022-08-10 10:58:25.611387
updated_at2024-12-11 06:53:37.684871
descriptiona rust utils
homepagehttps://gitee.com/eternalnight996
repositoryhttps://gitee.com/eternalnight996/e-utils
max_upload_size
id642559
size395,280
Eternal (EternalNight996)

documentation

https://docs.rs/e-utils

README

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.

Commit count: 0

cargo fmt