Volume
Volume::get_default()
.fs(). The local backend returns a typed Unsupported error; it never substitutes a directory from the caller’s machine.
Example
Example
Volume::builder()
Example
Example
.disk() then .size() for a raw ext4 disk-image volume. Volume names must start with an alphanumeric character and contain only alphanumeric characters, dots, hyphens, and underscores. See VolumeBuilder for all options.
Parameters
nameimpl Into<String>“pip-cache”.Returns
Volume::create()
Example
Example
VolumeConfig. Routes through the active backend. Locally this inserts a database record and creates the host directory (formatting a disk.raw for disk volumes). Fails with VolumeAlreadyExists if a volume of the same name already exists. Most callers use Volume::builder(), which calls this internally.
Parameters
configVolumeConfigVolumeConfig is an alias for VolumeSpec.Returns
Volume::get()
Example
Example
VolumeNotFound if no volume by that name exists.
Parameters
name&strReturns
Volume::list()
Example
Example
Returns
Volume::remove()
Example
Example
VolumeNotFound if the volume does not exist.
Parameters
name&strInstance methods
A liveVolume, returned by Volume::create() or VolumeBuilder::create(). Carries the backend it was created on.
vol.name()
Returns
vol.kind()
Directory or Disk.
Returns
vol.fs()
Example
Example
tokio::fs; Cloud volumes route through the authenticated volume API. See VolumeFs for the operations.
Returns
vol.path()
Example
Example
Returns
~/.microsandbox/volumes/pip-cache/.vol.disk_path()
disk.raw) for disk volumes. Returns None for directory volumes.
Returns
disk.raw, or None for directory volumes.vol.capacity_bytes()
None for directory volumes.
Returns
None.vol.disk_format()
"raw" for managed disk volumes). None for directory volumes.
Returns
None.vol.disk_fstype()
"ext4" for managed disk volumes). None for directory volumes.
Returns
None.vol.backend_kind()
Local or Cloud.
Returns
Local or Cloud.vol.local()
Some for local-backed volumes and None otherwise.
Returns
None.vol.cloud()
Some for cloud-backed volumes and None otherwise.
Returns
None.VolumeHandle
Returned by Volume::get() · Volume::list()
A metadata and lifecycle handle for a named volume.h.name()
Returns
h.kind()
Directory or Disk.
Returns
h.fs()
Example
Example
VolumeFs.
Returns
h.remove()
Example
Example
h.used_bytes()
Volume::get() again for a fresh reading.
Returns
h.quota_mib()
None if unlimited.
Returns
None.h.capacity_bytes()
None for directory volumes.
Returns
None.h.disk_format()
None for directory volumes.
Returns
None.h.disk_fstype()
None for directory volumes.
Returns
None.h.disk_path()
disk.raw) for local disk volumes. None otherwise.
Returns
disk.raw, or None.h.labels()
Returns
h.created_at()
Returns
None.h.backend_kind()
Local or Cloud.
Returns
Local or Cloud.h.local()
Some for local-backed handles and None otherwise.
Returns
None.h.cloud()
Some for cloud-backed handles and None otherwise.
Returns
None.VolumeFs
Local operations remain confined to the opened volume directory, including symlink traversal, missing parents, streams, copy, rename, and recursive deletion. Paths that leave the volume return an error. A leading/ denotes the volume root; valid in-volume parent components and symlinks keep their meaning. Removing or renaming the volume root is refused.
Returned by Volume::fs() · VolumeHandle::fs()
Host-side filesystem operations for a named volume.fs.read()
Example
Example
Parameters
path&strReturns
fs.read_to_string()
Example
Example
Parameters
path&strReturns
fs.read_stream()
Example
Example
VolumeFsReadStream that yields 64 KiB chunks, so large files don’t have to be held in memory at once.
Parameters
path&strReturns
fs.write()
Example
Example
Parameters
path&strdataimpl AsRef<[u8]>fs.write_stream()
Example
Example
VolumeFsWriteSink that accepts chunks of bytes. Creates parent directories as needed.
Parameters
path&strReturns
fs.list()
Example
Example
Parameters
path&strReturns
fs.mkdir()
Example
Example
Parameters
path&strfs.remove()
Example
Example
remove_dir() for directories.
Parameters
path&strfs.remove_dir()
Example
Example
Parameters
path&strfs.copy()
Example
Example
Parameters
from&strto&strfs.rename()
Example
Example
Parameters
from&strto&strfs.stat()
Example
Example
Parameters
path&strReturns
fs.exists()
Example
Example
false rather than an error if the path is absent.
Parameters
path&strReturns
true if the path exists.VolumeBuilder
Returned by Volume::builder()
Builder for configuring a named volume.volume_builder.directory()
volume_builder.disk()
.size().
volume_builder.size()
Example
Example
u32 (MiB) or a SizeExt helper such as 20.gib().
Parameters
sizeimpl Into<Mebibytes>volume_builder.quota()
u32 (MiB) or a SizeExt helper such as 1.gib(). Omit for unlimited growth (the default). Rejected for disk volumes, which size up front via .size().
Parameters
sizeimpl Into<Mebibytes>volume_builder.label()
Parameters
keyimpl Into<String>valueimpl Into<String>volume_builder.build()
VolumeConfig without creating the volume. Pass the result to Volume::create() to provision it later.
Returns
volume_builder.create()
Example
Example
Volume::create(self.build()).
Returns
MountBuilder
Used by SandboxBuilder::volume()
Builder for configuring a sandbox volume mount.mount.bind()
,, :, or ;.
Parameters
hostimpl Into<PathBuf>mount.named()
Volume::create(). The volume must already exist. Persists across sandbox restarts and can be shared between sandboxes. For sandbox-time provisioning, use .named_with().
Parameters
nameimpl Into<String>mount.named_with()
Example
Example
NamedVolumeBuilder closure. existing (the default) behaves like .named(); create provisions the volume and fails if it already exists; ensure_exists provisions it if missing or reuses a compatible existing volume. The ensure-exists mode validates existing metadata and errors when the kind, quota, capacity, or explicitly requested labels differ; it does not mutate existing metadata.
Parameters
nameimpl Into<String>mount.tmpfs()
.size().
mount.disk()
.qcow2, .vmdk; anything else is Raw). Override with .format().
Parameters
hostimpl Into<PathBuf>mount.format()
.disk() mount. Valid only with .disk(); calling it on a bind, named, or tmpfs mount errors when the SandboxBuilder is finalized.
Parameters
formatDiskImageFormatmount.fstype()
.disk() mount, for example "ext4". If omitted, agentd probes /proc/filesystems and uses the first type that mounts cleanly. Empty values and the separators ,, ;, :, = are rejected. Valid only with .disk().
Parameters
fstypeimpl Into<String>mount.readonly()
EROFS).
mount.noexec()
sh /mnt/script.sh, because the interpreter binary executes from a different filesystem.
mount.nosuid()
mount.nodev()
mount.stat_virtualization()
Strict. Valid only for bind and directory-backed named-volume mounts. Tmpfs and disk-image mounts are rejected when the mount is built; disk-backed named volumes are rejected once the backing volume kind is known during sandbox create or start.
Parameters
policyStatVirtualizationmount.host_permissions()
Private. Valid only for bind and directory-backed named-volume mounts. Combining StatVirtualization::Off with HostPermissions::Mirror is rejected, since with no overlay the guest chmod already hits the host inode and Mirror would be a no-op.
Parameters
policyHostPermissionsmount.owner()
StatVirtualization::Off are rejected.
mount.size()
.tmpfs() mount. Accepts a bare u32 (MiB) or a SizeExt helper such as 1.gib(). Valid only for tmpfs mounts.
Parameters
sizeimpl Into<Mebibytes>mount.build()
SandboxBuilder::volume; call it directly only when assembling a VolumeMount by hand. Errors when no mount kind is set, the guest path is not absolute or is /, or a kind-specific option was set on the wrong mount kind.
Returns
NamedVolumeBuilder
Used by MountBuilder::named_with()
Sub-builder forMountBuilder::named_with(). Selects the sandbox-time existence behavior and, for create / ensure_exists, the creation metadata. Defaults to existing and directory-backed.
named.existing()
named.create()
named.ensure_exists()
named.name()
named_with().
Parameters
nameimpl Into<String>named.directory()
named.disk()
.size(). Clears any previously set quota.
named.size()
u32 (MiB) or a SizeExt helper.
Parameters
sizeimpl Into<Mebibytes>named.quota()
u32 (MiB) or a SizeExt helper.
Parameters
sizeimpl Into<Mebibytes>named.label()
ensure_exists, requested labels must match the existing volume. Can be called multiple times.
Parameters
keyimpl Into<String>valueimpl Into<String>VolumeFsReadStream
Returned by VolumeFs::read_stream()
A streaming reader for file data from a local volume directory.stream.recv()
None at EOF
Returns
Option<Bytes>
stream.collect()
Returns
Bytes
VolumeFsWriteSink
Returned by VolumeFs::write_stream()
A streaming writer for file data to a local volume directory.sink.write()
sink.close()
Types
VolumeKind
Storage kind for a named volume.Returned by Volume::kind() · VolumeHandle::kind()
VolumeSpec
Configuration for creating a named volume. Re-exported as bothVolumeSpec and the alias VolumeConfig.
Used by Volume::create() · returned by VolumeBuilder::build()
MountOptions
Guest mount behavior shared by every mount kind. Set via theMountBuilder toggles; all fields default to false.
StatVirtualization
Stat virtualization policy for a virtiofs-backed mount. Default:Strict. Set via MountBuilder::stat_virtualization().
HostPermissions
Host permission propagation policy for a virtiofs-backed mount. Default:Private. Set via MountBuilder::host_permissions().
DiskImageFormat
Disk image format for virtio-blk root filesystems and volume mounts. Used byMountBuilder::format().
NamedVolumeMode
Sandbox-time behavior for a named volume mount, chosen viaNamedVolumeBuilder.