Expand description
dvm.run’s SDK: command sessions or supplied programs, and point-in-time inspection.
let client = dvm_run::Client::from_env()?;
let sandbox = client.create_sandbox("alpine:3.20").command(["echo", "hello"]).await?;
assert_eq!(sandbox.wait().await?, 0);
assert_eq!(sandbox.output().await?.stdout.bytes(), b"hello\n");
let point = sandbox.seek_end().await?;
println!("{:?}", point.stat("/etc/os-release").await?.kind);Re-exports§
pub use dvm_api as api;
Structs§
- Client
- dvm.run’s API, at an address, as the user whose key it bears. Cheap to clone: clones share their connections.
- Command
- A started command. With omitted stdin the handle keeps it open.
- Command
Line - Argv (an array or vector), or a shell script (a string).
- Command
Result - A command’s bytes and exit code, or 128 + its killing signal. Nonzero is a result; the protocol cannot distinguish a signal from an explicit exit with that code.
- Logged
In - A login’s key, which
save_keykeeps where the SDK finds it. - RunBuilder
- Options for a command run to its end. Omitted stdin is closed empty.
- Sandbox
- A sandbox, from
Client::create_sandboxorClient::connect_sandbox. With neither command nor entrypoint it takes commands. Otherwise it is one run of the supplied program. Dropping it does not end or stop it. - Sandbox
Builder - What a sandbox is made of:
Client::create_sandbox, then what differs from 1 vCPU, 1024 MiB, seed 0, the image’s variables, and a name after the image; awaited, the sandbox, once it’s running. - Sandbox
Point - Seek
Builder - Start
Builder - Options for starting a command, applied before awaiting it.
- Stat
Builder - Step
Builder - Write
File Builder
Enums§
- Error
- What the SDK returns when a call fails. A program’s exit code is never one of these.
Constants§
Functions§
- credentials_
path - Where the keys are saved.
- login
- Logs this machine in to dvm.run at
api_url, elseDVM_API_URL, elsehttps://sandbox.dvm.run, once its user approves the login in their browser: the key it was given.sayis told what to do; withopen_browser, the page that approves it opens here. - save_
key - Saves
keyfor the dvm.run atapi_url, in place of the one saved for it before; the file it’s in.