1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! A type-safe Rust API for controlling Windows Sandbox through the `wsb` CLI.
//!
//! This crate is supported on Windows only.
//!
//! This crate provides:
//!
//! - [`SandboxEnvironment`] for interacting with running sandbox instances
//! - [`SandboxEnvironmentBuilder`] for starting new sandbox instances
//! - [`SandboxConfig`] for constructing `.wsb`-compatible configuration XML
//! - [`SandboxId`] for working with sandbox identifiers returned by `wsb`
//!
//! The configuration model in [`config`] follows the Windows Sandbox `.wsb`
//! configuration format documented by Microsoft. For details, see
//! [Use and configure Windows Sandbox](https://learn.microsoft.com/en-us/windows/security/application-security/application-isolation/windows-sandbox/windows-sandbox-configure-using-wsb-file).
//!
//! The runtime API in this crate wraps the Windows Sandbox CLI. For command
//! behavior and arguments, see
//! [Windows Sandbox command line interface](https://learn.microsoft.com/en-us/windows/security/application-security/application-isolation/windows-sandbox/windows-sandbox-cli).
//!
//! # Examples
//!
//! Start a sandbox with a typed configuration:
//!
//! ```rust,no_run
//! use wsbx::{SandboxConfig, SandboxEnvironment};
//!
//! let environment = SandboxEnvironment::builder()
//! .config(
//! SandboxConfig::new()
//! .networking(false)
//! .memory_in_mb(4096),
//! )
//! .start()?;
//! # Ok::<(), wsbx::SandboxError>(())
//! ```
//!
//! Attach to an existing sandbox by ID and execute a command:
//!
//! ```rust,no_run
//! 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();
//! # Ok::<(), wsbx::SandboxError>(())
//! ```
//!
//! # Usage
//!
//! Add this to your `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! wsbx = "0.1.0"
//! ```
compile_error!;
pub use crate::;