Doe - A Versatile Rust Utility Crate
Doe is a versatile Rust crate that significantly enhances the development workflow by offering an extensive collection of useful macros and utility functions. It streamlines common tasks and provides convenient features for clipboard management, state management, keyboard input, and mouse interaction. Additionally, doe includes robust cryptographic functions, enabling developers to easily integrate secure encryption, decryption, and hashing capabilities into their applications, ensuring data integrity and confidentiality.
Features
Core Features
- Clipboard Management: Simplifies clipboard operations
- Cryptographic Functions: AES, RSA, SHA, MD5 and Blake3 implementations
- File System Utilities: Advanced file operations and management
- Random Number Generation: LCG-based random number generator
- System Utilities: Process management and system commands
Optional Features
To use specific features, add them to your Cargo.toml:
[]
= { = "1.0", = ["ctf", "clip", "mouse"] }
Available Features:
| Feature | Description | Command |
|---|---|---|
| ctf | String manipulation and encoding utilities | cargo add doe -F ctf |
| clip | Clipboard management | cargo add doe -F clip |
| mouse | Mouse input simulation | cargo add doe -F mouse |
| keyboard | Keyboard input simulation | cargo add doe -F keyboard |
| kcm | Keyboard, clipboard, and mouse combined | cargo add doe -F kcm |
| xlsx | Excel file manipulation | cargo add doe -F xlsx |
| docx | Word document manipulation | cargo add doe -F docx |
| date | Date and time utilities | cargo add doe -F date |
| screenshot | Screenshot capture and processing | cargo add doe -F screenshot |
| images | Image manipulation | cargo add doe -F images |
| crypto | Cryptographic functions | cargo add doe -F crypto |
| asyncrs | Async runtime utilities | cargo add doe -F asyncrs |
| logger | Logging utilities | cargo add doe -F logger |
| sqlserver | SQL Server database operations | cargo add doe -F sqlserver |
| axumserver | Axum server utilities | cargo add doe -F axumserver |
| ip_addr | IP address utilities | cargo add doe -F ip_addr |
| http | HTTP client and server utilities | cargo add doe -F http |
| process | Process management utilities | cargo add doe -F process |
| json | JSON manipulation utilities | cargo add doe -F json |
Modules
Core Modules
- asyncrs: Async runtime utilities for concurrent programming
- clipboard: Clipboard operations for copying and pasting data
- color: Color format conversions between RGB and HEX
- consts: Common constants used throughout the crate
- crypto: Cryptographic functions including AES, RSA, SHA, MD5 and Blake3
- ctf: String manipulation and encoding utilities
- date: Date and time utilities
- docx: Word document manipulation
- fs: File system operations
- httprs: HTTP request utilities
- images: Image manipulation
- ip_addr: IP address parsing and manipulation
- json: JSON manipulation
- keyboard: Keyboard input simulation
- logger: Logging utilities
- macros: Utility macros
- mouse: Mouse input simulation
- process: Process management
- rand: Random number generation
- screenshot: Screenshot utilities
- axumserver: Axum server utilities
- sqlserver: SQL Server database operations
- structs: Custom data structures
- timer: Timer utilities
- traits: Shared behavior definitions
- xlsx: Excel file manipulation
- zoml: ZOML format utilities
Usage
Add doe to your Cargo.toml:
[]
= "1.0"
Examples
crypto example
let data = "this is data".as_bytes;
let enc_data = aes_ecb_encrypt.unwrap;
let dec_data = aes_ecb_decrypt.unwrap;
println!;
println!;
println!;
println!;
keyboard example
// cargo add doe -F kcm
use key_click;
use key_press;
use key_release;
use KeyCode;
use mouse_drag;
use move_to_paste;
use move_to_press_left;
use *;
use exit_if_click_esc;
let list = vec!;
// crete new baogao
move_to_press_left.sleep; //#000000
// create fengmian
move_to_paste.sleep; //#000000
move_to_paste.sleep; //#000000
// add shuoming
move_to_paste.sleep; //#ffffff
mouse_drag.sleep; //#f0f0f0
key_click.sleep;
move_to_press_left.sleep; //#f0f0f0
for name in list
// set taoshu
move_to_paste.sleep; //#000000
docx_replace
//finds all 'name' and replace with 'andrew'
use *;
docx_replace.unwrap;
docx_get_content.unwrap.dprintln;
docx_remove_read_only.unwrap;
Spawn trait
use *;
use exit_if_click_esc;
let t1 = run.spawn;
let t2 = exit_if_click_esc.spawn;
t1.join;
t2.join;
listen keybord and mouse
automater
generate script
run to generate script
cargo r > script.m
script.m
);
);
);
);
);
;
);
);
);
);
);
);
);
run script
use automater;
let script = include_str!;
automater;
mouse automater
mouse press left drag
cargo add doe -F keyboard
keyboard example
control mouse
cargo add doe -F mouse
#arch linux
sudo pacman -S xdotool
#Fedora OR Red Hat
sudo dnf install libxdo-devel
#Ubuntu OR Debian
sudo apt install libxdo-dev
#Cargo.toml add
[build]
rustflags = ["-L", "/usr/local/lib"]
#OR Cargo.toml add
[build]
rustflags = ["-l", "xdo"]
CopyString is a structure that implements the Copy trait
use CopyString;
let mut s = default;
s.push_str;
s.push_str;
s.push_str;
s.push_str;
dbg!;
s.println;
let a = s;
let b = a;
b.println;
implments Bts struct and bts! macro for Box<dyn Fn()> trait object
implments Bts struct and bts! macro for Box<dyn ToString> trait object
implmemt Debug,Display,Clone,Default,Drop trait for Struct
implment format for impl ToString
implment print println eprint eprintln for impl Display, impl Debug
use Print;
use DebugPrint;
"printable text".print;//impl Display
"printable text".println;
"printable text".eprintln;
//impl Debug
let d = DebugPrintDemo;
d.dprint;
d.dprintln;
d.deprintln;
implment targets! for return Vec<(Box<dyn ToString>,Box<dyn ToString>)>
run timer by send stop_massge by channel
use mpsc;
use thread;
use Duration;
run timer by shared state
run timer anguments :start_time:Instant,step_time:Duration,stop_time:Duration,func:Box<dyn Fn()>
run_timer;
useage of fs module
like pythons os.system() function
implment cut format for str and String
use Str;
let a = "this is a demo {}";
let c = a.cut;
let f = a.format.format;
println!;
println!;
convert type
use *;
let s = as_to!;
assert_eq!;
if type is i8 return true
use *;
assert_eq!;
if type is i16 return true
use *;
assert_eq!;
if type is i32 return true
use *;
assert_eq!;
if type is i64 return true
use *;
assert_eq!;
if type is i128 return true
use *;
assert_eq!;
if type is f32 return true
use *;
assert_eq!;
if type is f64 return true
use *;
assert_eq!;
returns a raised to the b power
use *;
let p = powf!;
assert_eq!;
get argument and collect into Vec<String>
use *;
//cargo run -- -n 100
let arg = args!;
assert_eq!;
get user input from terminal,return String
use *;
let s = input!;
println!;
Spliy &str by spliter and collect into Vec<String>
use *;
let s = split_to_vec!;
assert_eq!;
read .csv file and Collect into Vec<Vec<String>>
use *;
let s = read_csv!;
assert_eq!;
sorted new Vec
use *;
let s1 = sorted!;
let s2 = sorted!;
assert_eq!;
assert_eq!;
sorted and deduped Vec
use *;
let s1 = deduped_sorted!;
let s2 = deduped_sorted!;
assert_eq!;
assert_eq!;
parse Vec element to type, parse Vec<&str> Collect to Vec<type>
use *;
let v1: = vec_element_parse!;
let v2: = vec_element_parse!;
let v3: = vec_element_parse!;
assert_eq!;
assert_eq!;
assert_eq!;
convert vec item to String,return Vec<String>
use *;
let v1 = vec_element_to_string!;
let v2 = vec_element_to_string!;
let v3 = vec_element_to_string!;
assert_eq!;
assert_eq!;
assert_eq!;
return the array elements arranged from outermost elements to the middle element, traveling clockwise (n x n)
use *;
let v1 = snail_sort!;
let v2 = snail_sort!;
assert_eq!;
assert_eq!;
mutiply two matrix
use *;
let m1 = .map.to_vec;
let m2 = .map.to_vec;
let mul_result1 = multiply_matrix!;
assert_eq!;
let m11 = .map.to_vec;
let m22 = .map.to_vec;
let mul_result2 = multiply_matrix!;
assert_eq!;
let m111 = .map.to_vec;
let m222 = .map.to_vec;
let mul_result3 = multiply_matrix!;
assert_eq!;
find the fist element and remove
use *;
let v1 = vec_element_remove!;
let v2 = vec_element_remove!;
let v3 = vec_element_remove!;
assert_eq!;
assert_eq!;
assert_eq!;
find element position and collect into Vec
use *;
let v1 = vec_element_position_all!;
assert_eq!;
let v2 = vec_element_position_all!;
assert_eq!;
slice vec by range
use *;
let v1 = vec_slice!;
let v2 = vec_slice!;
let v3 = vec_slice!;
let v4 = vec_slice!;
let v5 = vec_slice!;
let v6 = vec_slice!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
clone element by index
use *;
let v1 = vec_element_clone!;
let v2 = vec_element_clone!;
let v3 = vec_element_clone!;
let v4 = vec_element_clone!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
remove file or folder
remove_file_or_folder!;
remove_file_or_folder!;
get vec type ,return string type value
use *;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
convert vec elements type
use *;
let v1: = vec_element_convert!;
let v2: = vec_element_convert!;
let v3: = vec_element_convert!;
let v4: = vec_element_convert!;
let v5: = vec_element_convert!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
expr return max value
use *;
let re_max = max!;
assert_eq!;
expr return min value
use *;
let re_min = min!;
assert_eq!;
convert binary string to decimal
use *;
let d1 = binary_to_decimal!;
assert_eq!;
let d2 = binary_to_decimal!;
assert_eq!;
let d3 = binary_to_decimal!;
assert_eq!;
let d4 = binary_to_decimal!;
assert_eq!;
let d5 = binary_to_decimal!;
assert_eq!;
expr return memory address
use *;
let d1 = binary_to_decimal!;
println!;//0x7ffcac734f08
Merge two Vec return merged Vec
use *;
let v1 = vec_merge!;
assert_eq!;
let v2 = vec_merge!;
assert_eq!;
take size of elements and return a new vec
use *;
let v1 = vec_element_take!;
assert_eq!;
zip two vec elements in tuple
use *;
let v1 = vec_zip!;
assert_eq!;
enumerate all indexs and elements collect tuple of vec
use *;
let v1 = vec_enumerate!;
assert_eq!;
sort vec and return sorted vec
use *;
let v1 = vec_sort!;
assert_eq!;
let v2 = vec_sort!;
assert_eq!;
has stable rust nightly return bool
use *;
let v1 = has_nightly_compiler!;
assert_eq!;
has stable rust compiler return bool
use *;
let v1 = has_stable_compiler!;
assert_eq!;
run command
use *;
command!;
command!;
command!;
run a function once after a particularized delay(millis)
use *;
set_timeout!;
run a function after a particularized delay(millis) each run delay(millis)
use *;
duration_set_timeout!; //from now delay 3000ms,each 1000ms run func()
run a function repeatedly, beginning after some millis, then repeating continuously at the given interval.
use *;
set_interval!;
get current UTC-timestamp
use *;
let t = utc_timestamp!;
eprintln!;
get Local now
use *;
let t = local_now!;
eprintln!;
get Utc now
use *;
let t = utc_now!;
eprintln!;
macro for HashMap
use *;
use HashMap;
let mut map: = hashmap!;
map.insert;
let map1 = hashmap!;
macro for BTreeMap
use *;
use BTreeMap;
let mut map: = btreemap!;
map.insert;
let map1 = btreemap!;
License
This project is licensed under the MIT License - see the LICENSE file for details.