pub struct Namespace { /* private fields */ }Expand description
A mount table and the five verbs over it: walk, read, stat (the manifest verb), write and watch.
Cheap to clone (the backends are shared).
Grants are per mount, not per host directory. A ReadOnly mount refuses writes made through it; it does not stop a
ReadWrite mount (or another process) that reaches the same host files by another route. The embedder chooses the
host directories and must keep them disjoint. build() refuses only the same directory mounted twice; an ancestor
and a descendant mounted together are not detected, because the Kit holds no host paths. See the
module docs.
Implementations§
Source§impl Namespace
impl Namespace
Sourcepub fn builder() -> NamespaceBuilder
pub fn builder() -> NamespaceBuilder
Start a mount table.
Sourcepub fn mounts(&self) -> impl Iterator<Item = (&NsPath, Access, Caps)> + '_
pub fn mounts(&self) -> impl Iterator<Item = (&NsPath, Access, Caps)> + '_
The mount points, with their grants and the capabilities their backends declare.
Sourcepub fn walk(&self, path: &NsPath) -> NsResult<Vec<Entry>>
pub fn walk(&self, path: &NsPath) -> NsResult<Vec<Entry>>
List a directory. See the module docs for how mount ancestors and shadowing are handled.
Sourcepub fn read(&self, path: &NsPath, max: u64) -> NsResult<(Vec<u8>, Version)>
pub fn read(&self, path: &NsPath, max: u64) -> NsResult<(Vec<u8>, Version)>
Read a whole file, at most max bytes (TooLarge otherwise; nothing is truncated).
Sourcepub fn stat(&self, path: &NsPath) -> NsResult<Stat>
pub fn stat(&self, path: &NsPath) -> NsResult<Stat>
The manifest verb: kind, size, version and, where the backend has them, owner, mode and link count.
Sourcepub fn write(
&self,
path: &NsPath,
op: WriteOp,
data: &[u8],
if_version: Option<&Version>,
) -> NsResult<Version>
pub fn write( &self, path: &NsPath, op: WriteOp, data: &[u8], if_version: Option<&Version>, ) -> NsResult<Version>
Apply a WriteOp. The grant is checked first (ReadOnly is PermissionDenied), then the backend’s
capability. if_version is exact or best effort according to the backend’s Caps::exact_if_version.
A RenameWithinMount whose destination is under a different mount is CrossMount.
Sourcepub fn watch(&self, path: &NsPath, opts: WatchOpts) -> NsResult<Watch>
pub fn watch(&self, path: &NsPath, opts: WatchOpts) -> NsResult<Watch>
Watch a directory. Batches carry namespace paths. The watch sees changes inside the mount that covers path; a
recursive watch does not descend into mounts nested below it. A directory that exists only as a mount ancestor
cannot be watched (Unsupported): watch the mounts.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Namespace
impl !UnwindSafe for Namespace
impl Forget for Namespace
impl Freeze for Namespace
impl Move for Namespace
impl Send for Namespace
impl Sync for Namespace
impl Unpin for Namespace
impl UnsafeUnpin for Namespace
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more