wslcsdk
Idiomatic, safe, and asynchronous Rust SDK for Microsoft WSL Containers (WSLC).
Built against Microsoft's official Microsoft.WSL.Containers (Version 3.0.1 GA), this crate provides modern, memory-safe, and production-grade Rust interfaces to manage WSL-native micro-VM containers.
Features
- Strict RAII Lifetime Management: Automatically closes native C handles (
WslcSession,WslcContainer,WslcProcess,WslcCrashDumpSubscription) upon drop. - Streaming Process I/O: Captures stdout/stderr via native C trampolines and feeds them into bounded asynchronous channels. The receivers it exposes are runtime-agnostic, so no third-party async runtime type leaks into the public API.
- Two-Layer Typed Error Domain:
WslcDomainErrormirrors the 19 named HRESULTs of the official header one-to-one, while infrastructure failures stay in the outerWslcError. Unrecognized standard HRESULTs are reported by name instead of a misleading generic message. - Non-blocking Async Extensions: Provides
_asyncmethods offloaded totokio::task::spawn_blockingwith COM MTA automatic initialization. - Volume and Image Management: Built-in VHD volume options and image pull/list/delete abstractions.
Installation
Add this crate to your Cargo.toml:
[]
= "0.3.0"
= { = "1", = ["rt-multi-thread", "macros"] }
Compatibility:
wslcsdk 0.2.xis built on top ofwslcsdk-sys 3.0.1and requires Windows 11 with WSL 2.9.3+ or 3.0.1+.
Usage Example
use ;
async
License
This project is licensed under the MIT License.