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;
29mod client;
30mod error;
31mod process;
32mod sandbox;
33pub mod transport;
34mod types;
35
36pub mod images;
37pub mod networks;
38pub mod system;
39pub mod volumes;
40
41pub use binary::{reset_binary_cache, resolve_binary, set_binary_path};
42pub use client::{
43    BsdOs, Client, FollowLogsBuilder, RunBsdBuilder, RunFlavorBuilder, RunLinuxBuilder,
44    RunNanosBuilder, RunOsvBuilder, RunSolo5Builder, RunUnikraftBuilder, ShellBuilder,
45    ShellSession, Subscription,
46};
47pub use error::{Error, Result};
48pub use process::{run, run_checked, spawn, RawResult};
49pub use sandbox::{
50    CommandBuilder, FirmwareBuilder, FreebsdBuilder, KernelBuilder, LinuxBuilder, NanosBuilder,
51    NetbsdBuilder, OsvBuilder, Sandbox, Solo5Builder, SshSetupBuilder, TailscaleUpBuilder,
52    UnikraftBuilder, UpdateBuilder,
53};
54pub use transport::{normalize_url, ws_url, TOKEN_ENV, URL_ENV};
55pub use types::{
56    CommandResult, ExecResult, ImageInfo, NetworkInfo, PortForward, RemoteExecResult, SandboxInfo,
57    ShellSessionInfo, VolumeInfo,
58};