doe — Versatile Rust Utility Crate
doe bundles encoding helpers, cryptographic primitives, clipboard, keyboard & mouse simulation, screenshot capture, HTTP & JSON utilities, date/time, Excel & DOCX manipulation, structured logging, an async runtime, and more — every feature opt-in, minimal dependencies.
Installation
[]
= { = "1", = ["ctf", "crypto", "date"] }
Feature flags
| Feature | What it enables |
|---|---|
ctf |
Hex, base64, URL, hashing, regex, Chinese text, HTML parsing |
clip |
Clipboard read & write |
keyboard |
Keyboard input simulation |
mouse |
Mouse movement, click, drag, scroll |
kcm |
Keyboard + clipboard + mouse combined |
crypto |
AES, RSA, SHA-1/2/3, Blake3, SM2/3/4, MD5, RIPEMD-160 |
screenshot |
Screen capture — Windows GDI / macOS CoreGraphics / Linux X11+Wayland |
images |
Image resize, padding, ICO & ICNS conversion |
date |
Date/time formatting, Excel serial-date conversion |
xlsx |
Read & write .xlsx files |
docx |
Read & write .docx files |
exiftool |
EXIF metadata extraction |
httprs |
Simplified reqwest HTTP client (sync & async) |
json |
json! macro, to_json_value, as_bytes |
asyncrs |
Tokio runtime + block_on + async command |
logger |
Tracing-subscriber with file appender & env-filter |
sqlserver |
Deadpool Tiberius SQL Server pool |
axumserver |
Axum HTTP server (CORS, TLS, rate-limit) |
ip_addr |
Local IP / interface discovery |
process |
Enumerate & kill processes |
sys_random |
Cryptographically secure random bytes & UUID v4 |
full |
All of the above |
Always available (no feature needed): utils (hex/base64/percent/temp),
color, fs, system/command, rand, macros, traits, timer,
zoml, structs, DynError<T>.
Quick start
use utils; // always available
assert_eq!;
assert_eq!;
Examples
utils — encoding & temp (no feature)
use utils;
// Hex
assert_eq!;
assert_eq!;
// Base64 (standard, no-pad, URL-safe)
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
// Percent-encoding
let enc = encode;
assert_eq!;
assert_eq!;
// RAII temporary directory
// cleaned up automatically
color — RGB / hex (no feature)
use color;
assert_eq!;
assert_eq!;
fs — file-system (no feature)
use fs;
use Path;
// Walk directories
let files = walk_dir_get_files.unwrap;
let folders = walk_dir_get_folders.unwrap;
// Copy / move single files
copy_file.unwrap;
move_file.unwrap;
// Copy / move entire folders
copy_folder.unwrap;
move_folder.unwrap;
// Append & remove read-only
append_data_to_file.unwrap;
set_not_readonly.unwrap;
system / command — shell (no feature)
use ;
system.unwrap; // fire & forget
let out = command.unwrap; // capture output
println!;
println!;
assert!;
rand — LCG PRNG (no feature)
use LCG;
let mut rng = LCGnew;
println!;
println!;
macros — utility macros (no feature)
use *;
vec!.dprintln; // debug-print with file:line prefix
"hello".dprintln;
if has_powershell!
traits — common traits (no feature)
use *;
use *;
// DebugPrint
"hello".dprintln; // [src/main.rs:5] "hello"
vec!.dprintln;
// Sleep — call .sleep(secs) on any value
let x = 42.sleep; // waits 500 ms, then x == 42
// Spawn — .spawn() convenience
let handle = .spawn;
handle.join.unwrap;
timer — scheduled tasks (no feature)
use run_timer;
use ;
run_timer;
zoml — ZOML / CSV (no feature)
use zoml;
let csv = "name,age\nAlice,30\nBob,25";
let zoml = csv_to_zoml.unwrap;
let back = zoml_to_csv.unwrap;
assert_eq!;
structs — Bfn / Bts (no feature)
use *;
// Bfn: buffered file read/write
let bfn = new;
bfn.write.unwrap;
assert_eq!;
crypto (-F crypto)
use crypto;
// SHA family
assert_eq!;
println!;
println!;
println!;
println!;
println!;
// AES-256-CBC
let key = b"12345678123456781234567812345678";
let iv = b"1234567812345678";
let enc = aes_cbc_encrypt.unwrap;
let dec = aes_cbc_decrypt.unwrap;
assert_eq!;
// AES-GCM (authenticated encryption)
let key = b"0123456789abcdef0123456789abcdef";
let nonce = b"0123456789abcdef";
let aad = b"additional data";
let enc = aes_gcm_encrypt.unwrap;
let dec = aes_gcm_decrypt.unwrap;
assert_eq!;
// RSA
let = generate_keypair;
let enc = encrypt.unwrap;
let dec = decrypt.unwrap;
assert_eq!;
// SM2 sign & verify
let sig = sm2_sign.unwrap;
let ok = sm2_verify.unwrap;
assert!;
ctf — encoding & text (-F ctf)
use *;
// Hex
assert_eq!;
assert_eq!;
// Base64
assert_eq!;
assert_eq!;
// URL encode / decode
assert_eq!;
assert_eq!;
// Chinese detection & conversion
assert!;
assert!;
assert_eq!;
// Pinyin conversion
let py = convert_to_pinyin_with_non_chinese;
println!; // ce_shi_test
// HTML parsing
let html = r#"<html><body><a href="/x">link</a></body></html>"#;
let links = parse_html;
assert_eq!;
// Find URLs / PNG URLs in text
let urls = find_urls;
assert!;
// CtfParty trait (on &str and String)
use ;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
// Validation
assert!;
assert!;
assert!;
clipboard (-F clip)
use clipboard;
set_clipboard.unwrap;
let text = get_clipboard.unwrap;
assert_eq!;
keyboard (-F keyboard)
use ;
key_click; // press + release
key_press; // hold Ctrl, tap C
key_release; // release
// Virtual-key codes
key_press;
key_press;
key_press;
mouse (-F mouse)
use mouse;
// Move & click
move_to;
press;
// Right-click at position
move_and_press_right;
// Drag
mouse_drag;
// Scroll
scrool; // scroll up
scrool; // scroll down
screenshot (-F screenshot)
use screenshot;
// Capture all screens to PNG files
capture_all; // → screenshot_0.png, screenshot_1.png, …
// Crop a region from the primary screen
if let Some = capture_area
// Read a pixel from an image
if let Some = get_rgb_from_position
// Crop an existing image
use ;
let img = new;
let cropped = cut_area.unwrap;
images (-F images)
use images;
// Add white padding
image_add_padding;
// Resize
image_resize;
// Convert formats
convert_to_ico;
images_to_icns.unwrap;
date (-F date)
use date;
println!;
println!;
println!;
println!;
println!;
println!;
println!;
// Recent 7 days
let days = get_recent_seven_days;
for d in &days
// Excel serial date conversions
let excel_val = normal_date_to_excel_date.unwrap;
assert_eq!;
let iso = excel_date_to_normal_date.unwrap;
assert_eq!;
xlsx (-F xlsx)
use xlsx;
use cellvalue;
// Set cell values
xlsx_set_values.unwrap;
// Read a cell value
let val = xlsx_get_cell_value_str.unwrap;
println!;
// Read sheet names
let names = xlsx_get_sheet_names.unwrap;
println!;
// Replace values & save
xlsx_replace_values_save.unwrap;
// Column name helpers
assert_eq!;
assert_eq!;
docx (-F docx)
use docx;
// Replace placeholder text
docx_replace.unwrap;
// Extract all text content
let content = docx_get_content.unwrap;
println!;
// Remove read-only protection
docx_remove_read_only.unwrap;
exiftool (-F exiftool)
use exiftool;
// Read all metadata
let meta = run.unwrap;
if let Some = meta.get
// Filter by keyword
let camera = run_filtered.unwrap;
for in camera
// Get a single tag
let model = get_tag.unwrap;
println!;
httprs (-F httprs)
use httprs;
// Sync client with custom headers
let headers = headers!;
let client = sync_client_with_headers;
let body = client.sync_get_bytes.unwrap;
println!;
// Async client
use ;
// #[tokio::main]
// async fn main() {
// let client = async_client_with_headers(headers).await;
// let body = client.async_get_bytes("https://httpbin.org/get").await;
// }
json (-F json)
use ;
// Build JSON
let val = json!;
println!;
// Serialise to bytes
let bytes: = val.as_bytes;
// Deserialise from a string
let parsed = r#"{"key":"value"}"#.to_json_value;
asyncrs (-F asyncrs)
use asyncrs;
block_on;
// Custom multi-thread runtime
let rt = new_multi_thread
.enable_all
.build
.unwrap;
rt.block_on;
logger (-F logger)
use logger;
// Initialise (terminal + file appender + env filter)
init;
info!;
warn!;
error!;
ip_addr (-F ip_addr)
use ip_addr;
let addrs = get_addrs.unwrap;
for addr in addrs
process (-F process)
use process;
// List all running processes
let procs = get_all_process_name_and_pid;
for p in &procs
// Kill by name or PID
kill_process_by_name;
kill_process_by_pid;
sys_random (-F sys_random)
use sys_random;
// Cryptographically secure random bytes
let mut buf = ;
get_system_random_bytes.unwrap;
println!;
// UUID v4
let id = uuid;
println!; // e.g. "550e8400-e29b-41d4-a716-446655440000"
axumserver (-F axumserver)
use axumserver;
use ;
async
DynError — error alias (always available)
use DynError;
let config = read_config;
MSRV
1.73 — required for OnceLock and div_ceil used in utils.
License
MIT © Andrew (dnrops@outlook.com)