Skip to main content

bsdkrun_sdk/
lib.rs

1//! `bsdkrun` — a Rust SDK for [bsdkrun](https://github.com/tsirysndr/bsdkrun),
2//! a Firecracker-style microVM launcher for BSD, Linux, and unikernel guests.
3//!
4//! A thin, blocking wrapper: locally it builds argv, shells out to the
5//! `bsdkrun` binary, and parses the JSON output; remotely, [`Client`] drives
6//! the same operations against a `bsdkrund` daemon's GraphQL API. No async
7//! runtime anywhere.
8//!
9//! ```no_run
10//! use bsdkrun_sdk::Sandbox;
11//!
12//! let sandbox = Sandbox::linux("alpine")
13//!     .cpus(2)
14//!     .mem(1024)
15//!     .port("8080:80")
16//!     .command(["sleep", "300"])
17//!     .create()?;
18//!
19//! println!("{}", sandbox.exec(["uname", "-a"])?.text());
20//! sandbox.stop()?;
21//! # Ok::<(), bsdkrun_sdk::Error>(())
22//! ```
23//!
24//! Host-level operations live in the [`images`], [`volumes`], [`networks`]
25//! and [`system`] modules; the remote client in [`Client`].
26
27mod args;
28mod binary;
29pub mod cache;
30mod client;
31mod error;
32mod filesystem;
33mod process;
34mod sandbox;
35pub mod transport;
36mod types;
37
38pub mod images;
39pub mod networks;
40pub mod system;
41pub mod volumes;
42
43pub use binary::{reset_binary_cache, resolve_binary, set_binary_path};
44pub use cache::{Cache, CacheEntry, RestoreResult};
45pub use client::{
46    BsdOs, Client, FollowLogsBuilder, RunBsdBuilder, RunFlavorBuilder, RunLinuxBuilder,
47    RunNanosBuilder, RunOsvBuilder, RunSolo5Builder, RunUnikraftBuilder, ShellBuilder,
48    ShellSession, Subscription,
49};
50pub use error::{Error, Result};
51pub use filesystem::FileSystem;
52pub use process::{run, run_binary, run_checked, spawn, BinaryResult, RawResult};
53pub use sandbox::{
54    CommandBuilder, FirmwareBuilder, FreebsdBuilder, KernelBuilder, LinuxBuilder, NanosBuilder,
55    NetbsdBuilder, OsvBuilder, Sandbox, Solo5Builder, SshSetupBuilder, TailscaleUpBuilder,
56    UnikraftBuilder, UpdateBuilder,
57};
58pub use transport::{normalize_url, ws_url, TOKEN_ENV, URL_ENV};
59pub use types::{
60    CommandResult, ExecResult, ImageInfo, NetworkInfo, PortForward, RemoteExecResult, SandboxInfo,
61    ShellSessionInfo, VolumeInfo,
62};