wsbx 0.1.0

A type-safe Rust API for controlling Windows Sandbox, through the `wsb` CLI
Documentation

wsbx

Maintenance: actively-developed License: MIT OR Apache-2.0 crates.io docs.rs Rust: ^1.87.0 GitHub Actions: CI Codecov

A type-safe Rust API for controlling Windows Sandbox through the wsb CLI.

This crate is supported on Windows only.

This crate provides:

The configuration model in config follows the Windows Sandbox .wsb configuration format documented by Microsoft. For details, see Use and configure Windows Sandbox.

The runtime API in this crate wraps the Windows Sandbox CLI. For command behavior and arguments, see Windows Sandbox command line interface.

Examples

Start a sandbox with a typed configuration:

use wsbx::{SandboxConfig, SandboxEnvironment};

let environment = SandboxEnvironment::builder()
    .config(
        SandboxConfig::new()
            .networking(false)
            .memory_in_mb(4096),
    )
    .start()?;

Attach to an existing sandbox by ID and execute a command:

use wsbx::{RunAs, SandboxEnvironment, SandboxId};

let id: SandboxId = "12345678-1234-1234-1234-1234567890ab".parse()?;
let environment = SandboxEnvironment::from_id(id);
let result = environment.exec("cmd.exe", RunAs::System)?;
let _exit_code = result.exit_code();

Usage

Add this to your Cargo.toml:

[dependencies]
wsbx = "0.1.0"

Minimum supported Rust version (MSRV)

The minimum supported Rust version is Rust 1.87.0. At least the last 3 versions of stable Rust are supported at any given time.

While a crate is a pre-release status (0.x.x) it may have its MSRV bumped in a patch release. Once a crate has reached 1.x, any MSRV bump will be accompanied by a new minor version.

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

See CONTRIBUTING.md.