pub struct Client { /* private fields */ }Expand description
Talks the SDK ⇆ Gateway /sandboxes REST API and hands back Sandboxes.
Implementations§
Source§impl Client
impl Client
pub fn new(opts: ClientOptions) -> Result<Self, SolariError>
Sourcepub async fn create(&self, opts: CreateOptions) -> Result<Sandbox, SolariError>
pub async fn create(&self, opts: CreateOptions) -> Result<Sandbox, SolariError>
Create a new headless sandbox (POST /sandboxes).
Sourcepub async fn create_desktop(
&self,
opts: CreateOptions,
) -> Result<Sandbox, SolariError>
pub async fn create_desktop( &self, opts: CreateOptions, ) -> Result<Sandbox, SolariError>
Create a GUI desktop VM (POST /sandboxes with kind:"desktop").
Mirrors TS createDesktop() / Python create_desktop(). The returned
handle carries Sandbox::stream_url for the live view, and exposes the
same core namespaces as a sandbox (commands/files/code/git).
Driving the GUI (mouse/keyboard/screenshot) is not part of this surface.
Requires the desktop entitlement on the org’s plan; the gateway
answers 402 FeatureRequiresPlan otherwise.
Sourcepub async fn connect(&self, sandbox_id: &str) -> Result<Sandbox, SolariError>
pub async fn connect(&self, sandbox_id: &str) -> Result<Sandbox, SolariError>
Re-attach to a running sandbox by id (GET /sandboxes/:id).
Sourcepub async fn get(&self, sandbox_id: &str) -> Result<SandboxView, SolariError>
pub async fn get(&self, sandbox_id: &str) -> Result<SandboxView, SolariError>
Fetch a sandbox’s current view (GET /sandboxes/:id).
Sourcepub async fn kill(&self, sandbox_id: &str) -> Result<(), SolariError>
pub async fn kill(&self, sandbox_id: &str) -> Result<(), SolariError>
Destroy a sandbox (DELETE /sandboxes/:id). Idempotent.
Sourcepub async fn pause(&self, sandbox_id: &str) -> Result<(), SolariError>
pub async fn pause(&self, sandbox_id: &str) -> Result<(), SolariError>
Pause a session (POST /sandboxes/:id/pause): snapshot its RAM+disk and
free its host slot. The session keeps its id; bring it back with
Client::resume.
Sourcepub async fn resume(&self, sandbox_id: &str) -> Result<String, SolariError>
pub async fn resume(&self, sandbox_id: &str) -> Result<String, SolariError>
Resume a paused session (POST /sandboxes/:id/resume) and return the
control URL to re-attach to.
The session comes back on a FRESH slot, so its pre-pause control URL is
stale. The gateway normally returns the new one; when it does not, derive
it from the gateway origin exactly as Client::connect does.
Sourcepub async fn start(&self, sandbox_id: &str) -> Result<String, SolariError>
pub async fn start(&self, sandbox_id: &str) -> Result<String, SolariError>
Cold-boot a STOPPED sandbox (POST /sandboxes/:id/start) from the disk the
host kept, and return the fresh control URL to re-attach to.
A sandbox is stopped when its guest powered itself off. This is a cold boot, not a resume: running processes and memory are gone, files on disk are kept. It takes a concurrency slot (429 at the cap) and opens a new billing segment. Idempotent: an already-running sandbox answers 200 and its current control URL.
Any other state is refused with SolariError::Gateway { status: 409, code }
where code is NotStopped (use Client::resume for a paused one) or
StartInProgress. A stopped disk that cannot be started answers 409 with
its code (StoppedDiskMissing, StoppedDiskUnsafe, GoldenMismatch,
DiskPlatformMismatch, DiskShaMismatch, DiskExceedsSpec,
DiskOwnerMismatch). 409 HostCapabilityMissing means the host pool is not
armed for start (not retryable). 503 NoCapacity / StartTimeout is
SolariError::NoCapacity and 502 StartHostError is a gateway error, both
retryable; 500 StartFailed is not, and leaves the sandbox stopped with its
disk, so a later start is safe.