Expand description
bsdkrun — a Rust SDK for bsdkrun,
a Firecracker-style microVM launcher for BSD, Linux, and unikernel guests.
A thin, blocking wrapper: locally it builds argv, shells out to the
bsdkrun binary, and parses the JSON output; remotely, Client drives
the same operations against a bsdkrund daemon’s GraphQL API. No async
runtime anywhere.
use bsdkrun_sdk::Sandbox;
let sandbox = Sandbox::linux("alpine")
.cpus(2)
.mem(1024)
.port("8080:80")
.command(["sleep", "300"])
.create()?;
println!("{}", sandbox.exec(["uname", "-a"])?.text());
sandbox.stop()?;Host-level operations live in the images, volumes, networks
and system modules; the remote client in Client.
Re-exports§
pub use cache::Cache;pub use cache::CacheEntry;pub use cache::RestoreResult;pub use transport::normalize_url;pub use transport::ws_url;pub use transport::TOKEN_ENV;pub use transport::URL_ENV;
Modules§
- cache
- Cached guest directories —
Sandbox::cache, plus host-level listing. - ci
- CI workflows defined in code instead of YAML.
- images
- Host-level image operations.
- networks
- Global-network operations — reach machines by name on a shared subnet.
- system
- Host toolchain / image operations that aren’t tied to a single machine.
- transport
- The GraphQL transport for talking to a remote
bsdkrund. - volumes
- Host-level volume operations.
Structs§
- AiAgent
- A coding agent bsdkrun can sandbox.
- AiSession
- One agent sandbox. It is a machine, so
logs/stopwork onid. - AiStart
Builder - An
aiStartmutation being assembled — seeClient::ai_start. - Binary
Result - Like
RawResult, but stdout is left as bytes. - Branch
Builder - A
branchSnapshotmutation being assembled — seeClient::branch. - Client
- A client for a remote
bsdkrund’s GraphQL API. - Command
Builder - A guest command being assembled — see
Sandbox::command. - Command
Result - The outcome of a remote lifecycle mutation (stop/start/remove/update/commit).
- Docker
Container - A container in the Docker engine VM — a trimmed
docker psrow. - Docker
Start Builder - A
dockerStartmutation being assembled — seeClient::docker_start. - Docker
Status - The Docker engine VM: whether it is up, and how to reach it.
- Exec
Result - The captured result of running a command in a guest through the local CLI.
- File
System - Read and write files inside a running microVM.
- Firmware
Builder - Boots a raw disk through its UEFI loader (
bsdkrun firmware). - Follow
Logs Builder - A live log stream being assembled — see
Client::follow_logs. - Freebsd
Builder - Boots FreeBSD (
bsdkrun freebsd). - Image
Info - An image as reported by
bsdkrun images --json. - Kernel
Builder - Boots a kernel directly, no bootloader (
bsdkrun kernel). - Linux
Builder - Boots an OCI image as a Linux microVM (
bsdkrun linux). - Nanos
Builder - Boots a Nanos unikernel image (
bsdkrun nanos). - Netbsd
Builder - Boots NetBSD (
bsdkrun netbsd). - Network
Info - A global network as reported by
bsdkrun network ls --json. - OsvBuilder
- Boots an OSv unikernel image (
bsdkrun osv). - Port
Forward - A host to guest TCP port forward.
- RawResult
- The buffered result of a
bsdkruninvocation. - Remote
Exec Result - The captured result of
crate::Client::execagainst a remote daemon. - RunBsd
Builder - A
runBsdmutation being assembled — seeClient::run_bsd. - RunFlavor
Builder - A
runFlavormutation being assembled — seeClient::run_flavor. - RunLinux
Builder - A
runLinuxmutation being assembled — seeClient::run_linux. - RunNanos
Builder - A
runNanosmutation being assembled — seeClient::run_nanos. - RunOsv
Builder - A
runOsvmutation being assembled — seeClient::run_osv. - RunSolo5
Builder - A
runSolo5mutation being assembled — seeClient::run_solo5. - RunUnikraft
Builder - A
runUnikraftmutation being assembled — seeClient::run_unikraft. - Sandbox
- A handle to a running (or stopped) bsdkrun microVM.
- Sandbox
Info - A machine as reported by
bsdkrun ps --json(or the daemon’smachinesquery). - Shell
Builder - An
openShellmutation being assembled — seeClient::shell. - Shell
Session - A live interactive session opened by
Client::shell. - Shell
Session Info - A shell session as reported by
openShell/shellSessions. - Snapshot
Info - A machine snapshot: one machine’s disk state, captured under a name.
- Solo5
Builder - Boots a Solo5 (MirageOS) unikernel under the
solo5-hvttender (bsdkrun solo5). - SshSetup
Builder - An
ssh setupinvocation being assembled — seeSandbox::ssh_setup. - Subscription
- A raw subscription handle returned by
Client::subscribe. Dropping it does not unsubscribe — callSubscription::unsubscribe, matching the Python SDK’s explicit unsubscribe function. - Tailscale
UpBuilder - A
tailscale setupinvocation being assembled — seeSandbox::tailscale_up. - Unikraft
Builder - Boots a Unikraft unikernel (
bsdkrun unikraft). - Update
Builder - Pending vCPU / RAM changes — see
Sandbox::update. - Volume
Info - A volume as reported by
bsdkrun volume ls --json.
Enums§
- BsdOs
- The BSD to boot with
Client::run_bsd. - Error
- Every error the SDK raises.
Functions§
- reset_
binary_ cache - Reset cached discovery state and any override (mainly for tests).
- resolve_
binary - Resolve (and cache) the path to the
bsdkrunbinary. - run
- Run
bsdkrun <args>quietly (log level 0) and capture the result. - run_
binary - Run
bsdkrun <args>and keep stdout as raw bytes. - run_
checked - Like
run, but a non-zero exit becomesError::CommandFailedtagged withlabel. - set_
binary_ path - Force the SDK to use a specific
bsdkrunbinary, bypassing discovery. - spawn
- Run
bsdkrun <args>inheriting the parent’s stdio (interactive).
Type Aliases§
- Result
Resultalias used across the SDK.