list_dir, reindex, save/save_to, load, and verify remain
on the shared Snapshot API, but currently return
MicrosandboxError::Unsupported with the cloud backend.Static methods
Snapshot::builder()
name. Locally, the default destination
is ~/.microsandbox/snapshots/<name>/; in cloud, the default is managed object
storage. dest_dir() selects a local parent directory or a path on
the organization’s host volume. The source sandbox is set with
from_sandbox(), which is required.
Parameters
nameimpl Into<String>/, or start with ..Returns
Example
Example
Snapshot::create()
create().
Parameters
configSnapshotConfigReturns
Example
Example
Snapshot::open()
Example
Example
open_ref() when a typed
SnapshotReference is already available.
Parameters
path_or_nameimpl AsRef<str>Returns
Snapshot::open_ref()
SnapshotReference.
Use this when passing through a reference returned by another SDK operation;
it preserves whether the backend should resolve the value as an identifier or
a path.
Snapshot::get()
Example
Example
SnapshotHandle using the active
backend: the local index locally, or the managed snapshot API in cloud.
Parameters
name_or_digest&strReturns
Snapshot::list()
Example
Example
Returns
Snapshot::list_dir()
snapshot.json) and malformed artifacts.
Parameters
dirimpl AsRef<Path>Returns
Snapshot::remove()
Example
Example
force is set. The artifact directory is deleted on success and the parent’s child count is decremented.
Parameters
path_or_name&strforcebooltrue, remove even if the snapshot has indexed children.Snapshot::remove_ref()
remove() when the value came from
Snapshot::reference() or SnapshotHandle::reference().
Snapshot::reindex()
dir. Upserts an index row for every artifact found, then recomputes parent-edge child counts in one pass so the cache stays honest about the current set of artifacts.
Parameters
dirimpl AsRef<Path>Returns
Example
Example
Snapshot::reindex_default()
reindex() with the
local backend’s configured store and returns MicrosandboxError::Unsupported
on backends without a rebuildable artifact index.
Snapshot::save()
.tar.zst archive (or plain .tar) at out. Recorded payload integrity is preserved but not executed implicitly; call verify() when an independent content scan is part of your workflow. See SaveOpts to also include ancestors and the OCI image cache.
Parameters
name_or_path&strout&PathoptsSaveOptsSaveOpts::default() writes the head snapshot only, zstd-compressed.Example
Example
Snapshot::load()
Example
Example
.tar.zst or .tar, detected from magic bytes) into the snapshots directory (or dest), routing any bundled image-cache entries into the global cache and registering everything found in the index. Structural and archive-entry checks remain mandatory, while recorded payload integrity is preserved for explicit verify(). Returns a handle for the head snapshot.
Parameters
archive_path&PathdestOption<&Path>None uses the default snapshots directory.Returns
Example
Example
Instance methods
Methods on an openedSnapshot artifact.
snap.digest()
sha256:hex). This is the snapshot’s identity.
Returns
sha256:hex form.snap.reference()
SandboxBuilder::from_snapshot_ref(), Snapshot::open_ref(), and
Snapshot::remove_ref(). It contains either an identifier or a path in the
selected backend’s namespace; callers can pass it through without inspecting
which storage implementation produced it.
snap.manifest()
Example
Example
Manifest: schema, format, fstype, image reference, parent, creation time, labels, and upper-layer metadata.
Returns
snap.size_bytes()
Returns
snap.path()
MicrosandboxError::Unsupported because managed and host-volume artifacts are
not paths on the client host. Use reference() for backend-neutral restore and
lifecycle operations.
snap.save_to()
MicrosandboxError::Unsupported.
snap.verify()
Example
Example
NotRecorded without reading payload contents when the descriptor has integrity: null; errors with SnapshotIntegrity on mismatch. The cloud backend currently returns MicrosandboxError::Unsupported.
Returns
SnapshotHandle methods
Accessors and lifecycle on aSnapshotHandle returned by
the active backend. Returned by Snapshot::get(),
Snapshot::list(), and Snapshot::load().
h.digest()
sha256:hex), the canonical identity.
h.name()
None for digest-only entries.
h.parent_digest()
None for a root. Always None today; populated once chained snapshots land.
h.scope()
SnapshotScope::Disk for a disk-only snapshot, Resumable once resumable snapshots land. Always Disk today.
h.image_ref()
h.format()
Returns
Raw today).h.size_bytes()
h.path()
MicrosandboxError::Unsupported. Use reference() for backend-neutral restore
and lifecycle operations.
h.created_at()
h.open()
Example
Example
Returns
h.remove()
Example
Example
Parameters
forcebooltrue, remove even if the snapshot has indexed children.h.save_to()
MicrosandboxError::Unsupported.
Sandbox entry points
Snapshot-related methods that live on the sandbox builder and handle. See Sandbox for the full sandbox API..from_snapshot()
Example
Example
SandboxBuilder setter. Boot a fresh sandbox from a snapshot artifact. The snapshot already pins the image reference and digest, so this is mutually exclusive with image() and image_with(). The artifact is structurally opened at create() time; persistent payload integrity is checked only through explicit Snapshot::verify().
Parameters
path_or_nameimpl Into<String>.from_snapshot_ref()
Snapshot or SnapshotHandle reference into a new sandbox
without reinterpreting an identifier as a path.
h.snapshot()
SandboxHandle method. Snapshot this sandbox under a bare name using the
handle’s backend. Local uses its default snapshot directory; cloud uses managed
storage. The sandbox must be stopped or crashed; running sandboxes are rejected
with SnapshotSandboxRunning.
Parameters
name&strReturns
h.snapshot_to()
Example
Example
SnapshotBuilder
Builder for aSnapshotConfig. Obtained via Snapshot::builder(name). A source sandbox is required (from_sandbox); the other setters are optional. Every setter returns Self, so calls chain.
.from_sandbox()
build() and create() fail without it.
Parameters
source_sandboximpl Into<String>.dest_dir()
dest_dir/<name>; the name stays the snapshot’s identity either way.
Parameters
dest_dirimpl Into<PathBuf>.label()
Parameters
keyimpl Into<String>valueimpl Into<String>.force()
SnapshotAlreadyExists if the artifact directory exists.
.record_integrity()
verify() checks it explicitly; ordinary open, boot, save, load, and upgrade preserve the value without adding an independent payload pass.
.resumable()
create()
currently fails with Unsupported; resumable capture has not landed yet.
.build()
SnapshotConfig without creating the snapshot. Errors with InvalidConfig if from_sandbox was not called. For capturing, use create instead; it calls build internally.
Returns
.create()
Snapshot::create(self.build()?).
Returns
Types
SnapshotReference
A backend-neutral snapshot locator. Obtain one fromSnapshot::reference() or
SnapshotHandle::reference() and pass it to
SandboxBuilder::from_snapshot_ref(), Snapshot::open_ref(), or
Snapshot::remove_ref(). This preserves whether a value is an identifier or a
path without exposing the selected backend.
SnapshotReference::auto(), id(), or path() to construct a reference.
value() returns the underlying string and kind() returns auto, id, or
path.
SnapshotHandle
Returned by Snapshot::get() · Snapshot::list() · Snapshot::load()
A lightweight handle returned by the active backend. Useopen() to
read the snapshot metadata. The handle retains its backend, so open() and
remove() work without the caller interpreting its storage location.
SnapshotConfig
Used by Snapshot::create() · returned by build()
Inputs to create a snapshot. A type alias forSnapshotSpec. Usually built via SnapshotBuilder rather than constructed directly.
SnapshotFormat
Used by format() · Manifest.format
On-disk format of the captured upper layer. Today onlyRaw is produced; the variant exists so qcow2 chains drop in later without a schema migration.
SnapshotScope
Used by scope() · Manifest.scope
Snapshot payload scope. Parsing accepts every known scope so older runtimes can still list and inspect artifacts they cannot restore; create and restore paths enforce support. Re-exported asmicrosandbox::snapshot::SnapshotScope.
SaveOpts
Used by Snapshot::save() and instance save_to() methods
Snapshot::save() and instance save_to() methods. Implements Default; SaveOpts::default() writes the head snapshot only, zstd-compressed.
SnapshotVerifyReport
Returned by verify()
Result of explicit snapshot verification.UpperVerifyStatus
Used by SnapshotVerifyReport.upper
Upper-layer content verification result.Manifest
Returned by manifest()
The snapshot artifact manifest, the source of truth for an artifact, serialized as thesnapshot.json descriptor (DESCRIPTOR_FILENAME). Re-exported as microsandbox::snapshot::Manifest. Its SHA-256 digest over the canonical byte form is the snapshot’s identity. Field order is load-bearing (it determines the canonical byte layout) and must not be reordered.
ImageRef
Used by Manifest.image
Reference to the OCI image the snapshot was taken from. Re-exported asmicrosandbox::snapshot::ImageRef.
UpperLayer
Used by Manifest.upper
Captured upper-layer file metadata. Re-exported asmicrosandbox::snapshot::UpperLayer.
UpperIntegrity
Used by UpperLayer.integrity
Content integrity descriptor for the captured upper layer.