Skip to main content

ContentPath

Struct ContentPath 

Source
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

Source

pub fn placement(&self) -> &Placement

The volume this path lives in.

Source

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.

Source

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.

Source

pub fn open(&self) -> Result<File, ContainError>

Source

pub fn create(&self) -> Result<File, ContainError>

Source

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().

Source

pub fn append(&self) -> Result<File, ContainError>

Source

pub fn read(&self) -> Result<Vec<u8>, ContainError>

Source

pub fn metadata(&self) -> Result<Metadata, ContainError>

Metadata with symlinks followed, so an escaping link at any component refuses.

Source

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.

Source

pub fn file_len(&self) -> u64

Bytes held by the regular file at this path; 0 for anything else.

Source

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.

Source

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”.

Source

pub fn create_dir(&self) -> Result<(), ContainError>

Source

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.

Source

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.

Source

pub fn open_dir(&self) -> Result<Dir, ContainError>

Source

pub fn entries(&self) -> Result<ReadDir, ContainError>

Source

pub fn remove_file(&self) -> Result<(), ContainError>

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for ContentPath

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ContentPath

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more