sprites 0.1.0

Official Rust SDK for Sprites - stateful sandbox environments from Fly.io
Documentation
//! # Sprites SDK for Rust
//!
//! Official Rust client for the [Sprites](https://sprites.dev) API - stateful sandbox
//! environments from [Fly.io](https://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.
//!
//! ## Quick Start
//!
//! ```no_run
//! use sprites::SpritesClient;
//!
//! #[tokio::main]
//! async fn main() -> sprites::Result<()> {
//!     // Create a client with your API token
//!     let client = SpritesClient::new(std::env::var("SPRITES_TOKEN").unwrap());
//!
//!     // Create a sprite
//!     let sprite = client.create("my-sprite").await?;
//!
//!     // Run a command
//!     let output = sprite.command("uname").arg("-a").output().await?;
//!     println!("{}", output.stdout_str());
//!
//!     // Create a checkpoint
//!     let checkpoint = sprite.checkpoint("Initial state").await?;
//!     println!("Checkpoint: {}", checkpoint.id);
//!
//!     // Clean up
//!     sprite.destroy().await?;
//!
//!     Ok(())
//! }
//! ```
//!
//! ## Command Execution
//!
//! The [`Command`] struct mirrors [`std::process::Command`]:
//!
//! ```no_run
//! use sprites::SpritesClient;
//!
//! # #[tokio::main]
//! # async fn main() -> sprites::Result<()> {
//! let client = SpritesClient::new("token");
//! let sprite = client.sprite("my-sprite");
//!
//! let output = sprite
//!     .command("npm")
//!     .arg("install")
//!     .current_dir("/app")
//!     .env("NODE_ENV", "production")
//!     .output()
//!     .await?;
//!
//! if output.success() {
//!     println!("stdout: {}", output.stdout_str());
//! }
//! # Ok(())
//! # }
//! ```
//!
//! For long-running processes, use [`Command::spawn`] for streaming I/O:
//!
//! ```no_run
//! use sprites::SpritesClient;
//!
//! # #[tokio::main]
//! # async fn main() -> sprites::Result<()> {
//! let client = SpritesClient::new("token");
//! let sprite = client.sprite("my-sprite");
//!
//! let mut child = sprite.command("npm").arg("run").arg("dev").spawn().await?;
//!
//! // Wait for completion and get output
//! let status = child.wait().await?;
//! println!("Process exited with: {:?}", status);
//! # Ok(())
//! # }
//! ```
//!
//! ## Checkpoints
//!
//! Create snapshots for instant rollback (~300ms):
//!
//! ```no_run
//! use sprites::SpritesClient;
//!
//! # #[tokio::main]
//! # async fn main() -> sprites::Result<()> {
//! let client = SpritesClient::new("token");
//! let sprite = client.sprite("my-sprite");
//!
//! // Create a checkpoint before risky operations
//! let checkpoint = sprite.checkpoint("Before migration").await?;
//!
//! // Run migrations...
//! sprite.command("npm").arg("run").arg("migrate").output().await?;
//!
//! // If something goes wrong, restore instantly
//! sprite.restore(&checkpoint.id).await?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Network Policies
//!
//! Control what domains your sprite can access:
//!
//! ```no_run
//! use sprites::{SpritesClient, NetworkPolicy, NetworkPolicyRule, PolicyAction};
//!
//! # #[tokio::main]
//! # async fn main() -> sprites::Result<()> {
//! let client = SpritesClient::new("token");
//! let sprite = client.sprite("my-sprite");
//!
//! let policy = NetworkPolicy {
//!     rules: vec![
//!         NetworkPolicyRule {
//!             domain: "api.anthropic.com".into(),
//!             action: PolicyAction::Allow,
//!         },
//!         NetworkPolicyRule {
//!             domain: "*.npmjs.org".into(),
//!             action: PolicyAction::Allow,
//!         },
//!         NetworkPolicyRule {
//!             domain: "*".into(),
//!             action: PolicyAction::Deny,
//!         },
//!     ],
//!     include: vec![],
//! };
//!
//! sprite.set_policy(policy).await?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Feature Flags
//!
//! This crate uses [`rustls`](https://github.com/rustls/rustls) for TLS by default.
//! All async operations require a Tokio runtime.

mod client;
mod error;
mod exec;
mod filesystem;
mod proxy;
mod services;
mod session;
mod sprite;
mod types;

// Re-export main types
pub use client::{SpritesClient, SpritesClientBuilder, Version};
pub use error::{Error, Result};
pub use exec::{Child, ChildStderr, ChildStdin, ChildStdout, Command};
pub use filesystem::{DirEntry, FileInfo, Filesystem};
pub use proxy::{PortMapping, ProxySession};
pub use services::{
    ServiceLogEntry, ServiceLogStream, ServiceRequest, ServiceState, ServiceStatus, Signal,
};
pub use session::SessionInfo;
pub use sprite::{AttachCommand, Sprite};
pub use types::{
    Checkpoint, ExecOptions, ExitStatus, ListCheckpointsOptions, ListCheckpointsResponse,
    ListOptions, ListSpritesResponse, NetworkPolicy, NetworkPolicyRule, Output, PolicyAction,
    Session, SpriteConfig, SpriteInfo, SpriteStatus, StreamMessage, UrlAuth, UrlSettings,
};