| Crates.io | crosswin |
| lib.rs | crosswin |
| version | 0.3.0 |
| created_at | 2025-12-03 06:47:49.485563+00 |
| updated_at | 2026-01-12 03:02:58.878599+00 |
| description | Async-friendly Windows primitives for Rust with process management, memory monitoring, and system operations. |
| homepage | |
| repository | https://github.com/M1tsumi/crosswin |
| max_upload_size | |
| id | 1963471 |
| size | 97,065 |
Async-friendly Windows primitives for Rust.
A high-level, ergonomic wrapper around the Windows API that provides async process management, memory monitoring, and system operations without hiding what the OS is actually doing. Built on tokio for async operations and the windows crate for safe Win32 API bindings.
Active development. Version 0.3.0 adds window discovery/manipulation and system information queries on top of the existing process-management surface.
Supported (v0.3.0):
Planned (future):
tokio for non-blocking operationsAdd this to your Cargo.toml:
[dependencies]
crosswin = "0.2"
This crate targets Windows and requires tokio in your dependency tree.
use crosswin::prelude::*;
use crosswin::processes::list_processes;
#[tokio::main]
async fn main() -> Result<()> {
for process in list_processes().await? {
println!(
"PID {:>6} {:30} Memory: {:.2} MB Threads: {}",
process.pid,
process.name,
process.memory_usage_mb().unwrap_or(0.0),
process.thread_count.unwrap_or(0)
);
}
Ok(())
}
use crosswin::prelude::*;
#[tokio::main]
async fn main() -> Result<()> {
// Find process by name
if let Some(proc_info) = find_process_by_name("notepad").await? {
// Open with terminate access
let process = Process::open(proc_info.pid, ProcessAccess::Terminate)?;
// Terminate with exit code 0
process.terminate(0)?;
println!("Terminated process {}", proc_info.pid);
}
Ok(())
}
use crosswin::prelude::*;
#[tokio::main]
async fn main() -> Result<()> {
// Find memory-hungry Chrome processes
let processes = ProcessFilter::new()
.name_contains("chrome")
.min_memory(100_000_000) // 100 MB
.min_threads(5)
.list()
.await?;
println!("Found {} Chrome processes using >100MB", processes.len());
Ok(())
}
use crosswin::prelude::*;
use std::time::Duration;
#[tokio::main]
async fn main() -> Result<()> {
let proc_info = find_process_by_name("myapp").await?.expect("Process not found");
let process = Process::open(proc_info.pid, ProcessAccess::QueryInformation)?;
loop {
let mem = process.get_memory_info()?;
println!("Memory: {:.2} MB", mem.working_set_size as f64 / (1024.0 * 1024.0));
tokio::time::sleep(Duration::from_secs(1)).await;
}
}
Run the bundled examples:
cargo run --example list_processes # List all processes
cargo run --example kill_process notepad # Terminate by name
cargo run --example monitor_memory chrome # Track memory over time
cargo run --example process_tree # Show parent-child relationships
cargo run --example top_cpu 10 # Top 10 CPU consumers
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.