Snapshot
Snapshot::builder()
name, resolved under the default snapshots directory (~/.microsandbox/snapshots/<name>/) or under dest_dir() when set. The source sandbox is set with from_sandbox(), which is required; the other setters cover labels and whether to record content integrity before capturing. See SnapshotBuilder for all options.
Parameters
nameimpl Into<String>/, or start with ..Returns
Example
Example
Snapshot::create()
snapshot.json descriptor and the captured upper.ext4 into the artifact directory atomically (the descriptor is renamed into place last), then best-effort upserts a row into the local index. Index failures are logged but do not fail the call; the artifact is the source of truth. Most callers use the builder’s create() instead of constructing a SnapshotConfig by hand.
Parameters
configSnapshotConfigReturns
Example
Example
Snapshot::open()
Example
Example
. or ~) resolve under the default snapshots directory; anything else is treated as a path. This is a fast metadata operation: it verifies the manifest structure, recomputes the manifest digest, and checks that the upper file exists with the recorded size. It does not read the full upper contents; use verify() for that.
Parameters
path_or_nameimpl AsRef<str>Returns
Snapshot::get()
Example
Example
SnapshotHandle in the local index by name, digest (sha256:/sha512: prefix), or path.
Parameters
name_or_digest&strReturns
Snapshot::list()
Example
Example
list_dir to enumerate artifacts on disk directly.
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::reindex()
Example
Example
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::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.path()
snapshot.json descriptor and the captured upper file.
Returns
snap.manifest()
Example
Example
Manifest: schema, format, fstype, image reference, parent, creation time, labels, and upper-layer metadata.
Returns
snap.size_bytes()
Returns
snap.verify()
Example
Example
NotRecorded without reading payload contents when the descriptor has integrity: null; errors with SnapshotIntegrity on mismatch.
Returns
SnapshotHandle
Returned by Snapshot::get() · Snapshot::list() · Snapshot::load()
A snapshot handle backed by the local index.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.created_at()
h.path()
h.open()
Example
Example
Snapshot. Equivalent to Snapshot::open(self.path()).
Returns
h.remove()
Example
Example
Snapshot::remove(self.digest(), force).
Parameters
forcebooltrue, remove even if the snapshot has indexed children.SandboxBuilder
Snapshot-related methods that live on the sandbox builder and handle. See Sandbox for the full sandbox API.sandbox.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>SandboxHandle
h.snapshot()
SandboxHandle method. Snapshot this sandbox under a bare name in the default snapshots directory (~/.microsandbox/snapshots/<name>/). The sandbox must be stopped or crashed; running sandboxes are rejected with SnapshotSandboxRunning. Local handles only. To place the artifact elsewhere, use Snapshot::save() / Snapshot::load() or move the self-contained artifact directory.
Parameters
name&strReturns
h.snapshot_to()
Example
Example
SnapshotBuilder
Builder for snapshot configuration.snapshot_builder.from_sandbox()
build() and create() fail without it.
Parameters
source_sandboximpl Into<String>snapshot_builder.dest_dir()
dest_dir/<name>; the name stays the snapshot’s identity either way.
Parameters
dest_dirimpl Into<PathBuf>snapshot_builder.label()
Parameters
keyimpl Into<String>valueimpl Into<String>snapshot_builder.force()
SnapshotAlreadyExists if the artifact directory exists.
snapshot_builder.record_integrity()
verify() checks it explicitly; ordinary open, boot, save, load, and upgrade preserve the value without adding an independent payload pass.
snapshot_builder.resumable()
create() currently fails with Unsupported; resumable snapshots have not landed yet.
snapshot_builder.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
snapshot_builder.create()
Snapshot::create(self.build()?).
Returns
Types
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()
Options forSnapshot::save(). 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.