sprites-rs
Official Unofficial Rust SDK for Sprites - stateful sandbox environments from Fly.io.
Sprites are lightweight, persistent VMs powered by Firecracker. They hibernate when idle (no compute cost) and wake instantly when needed. Create checkpoints in ~300ms and restore to any previous state.
Installation
Add to your Cargo.toml:
[]
= "0.1"
= { = "1", = ["rt-multi-thread", "macros"] }
Quick Start
use SpritesClient;
async
Features
Command Execution
The Command API mirrors std::process::Command:
let output = sprite
.command
.arg
.current_dir
.env
.output
.await?;
if output.success else
For long-running processes, use spawn() for streaming I/O:
let mut child = sprite.command.arg.arg.spawn.await?;
// Wait for completion
let status = child.wait.await?;
println!;
Checkpoints
Create snapshots for instant rollback (~300ms):
// Checkpoint before risky operations
let checkpoint = sprite.checkpoint.await?;
// Run migrations...
sprite.command.arg.arg.output.await?;
// If something goes wrong, restore instantly
sprite.restore.await?;
// List all checkpoints
let checkpoints = sprite.list_checkpoints.await?;
for cp in checkpoints
Network Policies
Control egress with DNS-based filtering:
use ;
let policy = NetworkPolicy ;
sprite.set_policy.await?;
Filesystem Access
Read and write files without executing commands:
let fs = sprite.filesystem;
// Read a file
let content = fs.read_file.await?;
// Write a file
fs.write_file.await?;
// List directory
let entries = fs.read_dir.await?;
for entry in entries
Port Forwarding
Proxy local ports to your sprite:
// Forward local:8080 -> sprite:3000
let proxy = sprite.proxy_port.await?;
println!;
// Access your sprite's server at localhost:8080
// ...
proxy.close.await?;
Authentication
Get your API token from sprites.dev or exchange Fly.io credentials:
// Using Fly.io macaroon
let token = create_token.await?;
let client = new;
Configuration
Use the builder for advanced configuration:
use Duration;
let client = builder
.base_url
.timeout
.build;
Examples
See the examples directory:
# Basic usage
# Debug exec streaming
Related
- sprites-go - Official Go SDK
- Sprites CLI - Command-line interface
- Sprites Documentation - Full documentation
Contributing
See CONTRIBUTING.md for development setup and guidelines.
License
Apache-2.0 - see LICENSE for details.