Overview
The Rust SDK is the core implementation of BoxLite. It provides async-first APIs built on Tokio for creating and managing isolated VM environments. Crate:boxlite
Repository: github.com/boxlite-ai/boxlite
BoxliteRuntime
Main entry point for creating and managing boxes.Methods
| Method | Signature | Description |
|---|---|---|
new | fn new(options: BoxliteOptions) -> BoxliteResult<Self> | Create runtime with options |
with_defaults | fn with_defaults() -> BoxliteResult<Self> | Create with default options |
default_runtime | fn default_runtime() -> &'static Self | Get/create global singleton |
try_default_runtime | fn try_default_runtime() -> Option<&'static Self> | Get global if initialized |
init_default_runtime | fn init_default_runtime(options: BoxliteOptions) -> BoxliteResult<()> | Initialize global with options |
create | async fn create(&self, options: BoxOptions, name: Option<String>) -> BoxliteResult<LiteBox> | Create a new box |
get | async fn get(&self, id_or_name: &str) -> BoxliteResult<Option<LiteBox>> | Get box by ID or name |
get_info | async fn get_info(&self, id_or_name: &str) -> BoxliteResult<Option<BoxInfo>> | Get box info without handle |
list_info | async fn list_info(&self) -> BoxliteResult<Vec<BoxInfo>> | List all boxes |
exists | async fn exists(&self, id_or_name: &str) -> BoxliteResult<bool> | Check if box exists |
metrics | async fn metrics(&self) -> RuntimeMetrics | Get runtime-wide metrics |
get_or_create | async fn get_or_create(&self, options: BoxOptions, name: Option<String>) -> BoxliteResult<(LiteBox, bool)> | Get existing or create new box |
remove | async fn remove(&self, id_or_name: &str, force: bool) -> BoxliteResult<()> | Remove box completely |
shutdown | async fn shutdown(&self, timeout: Option<i32>) -> BoxliteResult<()> | Shut down runtime |
pull_image | async fn pull_image(&self, image_ref: &str) -> BoxliteResult<()> | Pre-pull an OCI image |
list_images | async fn list_images(&self) -> BoxliteResult<Vec<ImageInfo>> | List cached images |
Example
BoxliteOptions
Runtime configuration options.Example
Box Handle
LiteBox
Handle to a box instance. Thin wrapper providing access to box operations.Methods
| Method | Signature | Description |
|---|---|---|
id | fn id(&self) -> &BoxID | Get box ID |
name | fn name(&self) -> Option<&str> | Get optional box name |
info | fn info(&self) -> BoxInfo | Get box info (no VM init) |
start | async fn start(&self) -> BoxliteResult<()> | Start the box |
exec | async fn exec(&self, command: BoxCommand) -> BoxliteResult<Execution> | Execute command |
copy_into | async fn copy_into(&self, host_src, guest_dst, opts: CopyOptions) -> BoxliteResult<()> | Copy file into box |
copy_out | async fn copy_out(&self, guest_src, host_dst, opts: CopyOptions) -> BoxliteResult<()> | Copy file out of box |
metrics | async fn metrics(&self) -> BoxliteResult<BoxMetrics> | Get box metrics |
stop | async fn stop(&self) -> BoxliteResult<()> | Stop the box |
Lifecycle
start()initializes VM forConfiguredorStoppedboxes- Idempotent: calling on
Runningbox is a no-op exec()implicitly callsstart()if neededstop()terminates VM; box can be restarted
Example
BoxInfo
Public metadata about a box (returned by list operations).BoxStatus
Lifecycle status of a box.Methods
| Method | Signature | Description |
|---|---|---|
is_active | fn is_active(&self) -> bool | True if VM process running |
is_running | fn is_running(&self) -> bool | True if Running |
is_configured | fn is_configured(&self) -> bool | True if Configured |
is_stopped | fn is_stopped(&self) -> bool | True if Stopped |
is_transient | fn is_transient(&self) -> bool | True if Stopping |
can_start | fn can_start(&self) -> bool | True if Configured or Stopped |
can_stop | fn can_stop(&self) -> bool | True if Running |
can_remove | fn can_remove(&self) -> bool | True if Configured, Stopped, or Unknown |
can_run | fn can_run(&self) -> bool | True if Configured, Running, or Stopped |

