pub struct ContentPath { /* private fields */ }Expand description
A guest path resolved for an operation that reaches the path’s contents.
Carries the VFS root handle plus the root-relative path. Every component including the last is traversed under containment, so a symlink anywhere along the way that leaves the root is refused when the path is opened.
There is deliberately no accessor yielding a Path, and no Deref or AsRef:
a relative path handed to std::fs resolves against the server process working
directory, so std::fs::read("etc/passwd") from a process whose cwd is / would
be a host read with no diagnostic. Every consumer outside this module is therefore
a compile error rather than a silent reinterpretation.
Implementations§
Source§impl ContentPath
impl ContentPath
Sourcepub fn mounts_below(&self) -> Vec<(PathBuf, Arc<Dir>)>
pub fn mounts_below(&self) -> Vec<(PathBuf, Arc<Dir>)>
The mounts strictly below this directory, each as its path relative to this one and the handle of the volume behind it: what a recursive walk descends into in place of the empty mount point in the root.
Sourcepub fn writable(&self) -> Result<(), ContainError>
pub fn writable(&self) -> Result<(), ContainError>
Refuse when the volume is mounted read-only. Every mutation below checks this too; host functions call it first so the refusal comes before any other work and carries the caller.
pub fn open(&self) -> Result<File, ContainError>
pub fn create(&self) -> Result<File, ContainError>
Sourcepub fn create_new(&self) -> Result<File, ContainError>
pub fn create_new(&self) -> Result<File, ContainError>
Create, refusing if the path already exists. Race-free replacement for an
exists() check followed by create().
pub fn append(&self) -> Result<File, ContainError>
pub fn read(&self) -> Result<Vec<u8>, ContainError>
Sourcepub fn metadata(&self) -> Result<Metadata, ContainError>
pub fn metadata(&self) -> Result<Metadata, ContainError>
Metadata with symlinks followed, so an escaping link at any component refuses.
Sourcepub fn regular_file(&self) -> Option<(FileIdentity, u64)>
pub fn regular_file(&self) -> Option<(FileIdentity, u64)>
The regular file at this path and its size, without following a final
link; None for anything else, including nothing at all. What a write
that replaces this entry frees.
Sourcepub fn file_len(&self) -> u64
pub fn file_len(&self) -> u64
Bytes held by the regular file at this path; 0 for anything else.
Sourcepub fn refers_to(&self, identity: FileIdentity) -> Result<bool, ContainError>
pub fn refers_to(&self, identity: FileIdentity) -> Result<bool, ContainError>
Whether this path still names the file identity was taken from, the link
itself never followed. An escape along the way is reported, not answered
false.
Sourcepub fn try_exists(&self) -> Result<bool, ContainError>
pub fn try_exists(&self) -> Result<bool, ContainError>
Existence, with an escape reported as an ContainError::Escape for the caller
to translate. Dir::exists swallows the refusal and answers false, which would
conflate “outside the sandbox” with “not there”.
pub fn create_dir(&self) -> Result<(), ContainError>
Sourcepub fn is_existing_dir(&self) -> bool
pub fn is_existing_dir(&self) -> bool
Whether a directory is already here, links followed. mkdir -p of one
changes nothing, so it succeeds even in a read-only volume.
Sourcepub fn create_dir_all(&self) -> Result<(), ContainError>
pub fn create_dir_all(&self) -> Result<(), ContainError>
Like mkdir -p: a directory that already exists is success without any
change, even in a read-only volume; see is_existing_dir.
pub fn open_dir(&self) -> Result<Dir, ContainError>
pub fn entries(&self) -> Result<ReadDir, ContainError>
pub fn remove_file(&self) -> Result<(), ContainError>
Sourcepub fn rename_to(&self, dest: &Self) -> Result<(), ContainError>
pub fn rename_to(&self, dest: &Self) -> Result<(), ContainError>
Rename onto dest. Neither side’s final component is followed, so this cannot
be redirected by a link swapped in after resolution.
Sourcepub fn is_root(&self) -> bool
pub fn is_root(&self) -> bool
Whether this is the root of its volume: the VFS root or a mount point.
Writes and removes name it as a mistake rather than acting on it — remove
in particular would otherwise drain the root and then fail on the
self-unlink, destroying a volume and reporting a failure.
Sourcepub fn temp_sibling(&self) -> Self
pub fn temp_sibling(&self) -> Self
A collision-safe sibling for an atomic rename-into-place write, resolved through the same handle so the commit cannot be redirected.