pub struct Vfs { /* private fields */ }Implementations§
Source§impl Vfs
impl Vfs
Sourcepub fn none() -> Self
pub fn none() -> Self
A VFS that backs no directory. Every submilli:fs.* call traps; only
fs.info() works (reporting mode: none).
Sourcepub fn external_with_mode(root: PathBuf, mode: VfsMode) -> Result<Self>
pub fn external_with_mode(root: PathBuf, mode: VfsMode) -> Result<Self>
Mount an existing host directory the interpreter does not own. Used for
named roots and for per_session dirs owned by the server.
Sourcepub fn external(root: PathBuf) -> Result<Self>
pub fn external(root: PathBuf) -> Result<Self>
An existing host directory, as submilli run --vfs exposes it.
pub fn tempdir() -> Result<Self>
Sourcepub fn tempdir_in(parent: &Path) -> Result<Self>
pub fn tempdir_in(parent: &Path) -> Result<Self>
Like tempdir but allocated under parent (created if
absent). Lets the host place ephemeral scratch on a chosen volume.
Sourcepub fn root(&self) -> &Path
pub fn root(&self) -> &Path
The host path backing this VFS. Server-side logging and test setup only —
it is never the thing a guest path is resolved against. Empty for
VfsMode::None.
Sourcepub fn dir(&self) -> Option<&Arc<Dir>>
pub fn dir(&self) -> Option<&Arc<Dir>>
The capability handle guest paths resolve against, or None under
VfsMode::None.
A handle outlives the directory it was opened on: after the root is deleted
the handle still answers is_dir(), so it is not a liveness check.
pub fn mode(&self) -> VfsMode
Sourcepub fn with_size_limit(self, limit: u64) -> Self
pub fn with_size_limit(self, limit: u64) -> Self
Enforce limit bytes on the files this VFS holds, starting from what the
directory holds now; see with_measured_limit.
Sourcepub fn with_measured_limit(self, limit: u64, used: Option<u64>) -> Self
pub fn with_measured_limit(self, limit: u64, used: Option<u64>) -> Self
Enforce limit bytes, starting from used, what a walk of the directory
found. A directory already over the limit still opens: reads and removals
work, and writes that grow it are refused until it is back under. One that
couldn’t be measured (None) opens the same way, as if full, so a program
can still remove files and let a later run measure it.
Charge the root to quota, a limit the server shares between every VFS
that opens the same named volume.
Sourcepub fn quota(&self) -> Option<&Arc<DiskQuota>>
pub fn quota(&self) -> Option<&Arc<DiskQuota>>
The root’s size limit and its running count, when one applies.
Sourcepub fn with_access(self, access: Access) -> Self
pub fn with_access(self, access: Access) -> Self
Whether guest code may change the root. Mounts carry their own access.
pub fn access(&self) -> Access
Sourcepub fn with_volume_name(self, volume: &str) -> Self
pub fn with_volume_name(self, volume: &str) -> Self
Record the named volume backing the root, for fs.info().
pub fn volume(&self) -> Option<&str>
pub fn mounts(&self) -> &[Mount]
Sourcepub fn with_mount(self, spec: MountSpec) -> Result<Self, MountError>
pub fn with_mount(self, spec: MountSpec) -> Result<Self, MountError>
Graft the volume spec describes at its guest path.
In a writable root the mount point is created as an empty directory, so listing its parent shows it like any other directory. A read-only root is never written, so there the mount point must already exist.
pub fn with_mount_subpath( self, spec: MountSpec, sub_path: Option<&str>, ) -> Result<Self, MountError>
Sourcepub fn with_mount_quota(self, guest_path: &str, quota: Arc<DiskQuota>) -> Self
pub fn with_mount_quota(self, guest_path: &str, quota: Arc<DiskQuota>) -> Self
Charge the volume mounted at guest_path to quota, the limit the
server shares between every VFS that mounts it. No mount there is a
no-op.
Sourcepub fn locate(&self, rel: &Path) -> Option<(Arc<Dir>, PathBuf, Placement)>
pub fn locate(&self, rel: &Path) -> Option<(Arc<Dir>, PathBuf, Placement)>
Route a root-relative path (as the lexical pass produced it) to the
volume that holds it: the handle to open it through, the path relative
to that handle, and the volume’s placement. None under
VfsMode::None.
Matching is by whole components, so /memoryx is not under /memory.
A mount point itself resolves to its volume’s root, ..
pub fn with_cwd(self, cwd: &str) -> Result<Self, ContainError>
Sourcepub fn with_subpath(self, sub_path: Option<&str>) -> Result<Self>
pub fn with_subpath(self, sub_path: Option<&str>) -> Result<Self>
Select a directory through the volume handle, without ambient reopening.
Sourcepub fn measure_usage(&self) -> Result<u64>
pub fn measure_usage(&self) -> Result<u64>
The bytes held by regular files under the root; see measure_dir.