pub struct Dir { /* private fields */ }Expand description
An open directory: a pull-based listing cursor plus at-style child
operations taking ONE byte-exact name component (no / or NUL). The *_at
suite is the FFI-clean escape hatch for non-UTF-8 names discovered via
DirEntry::name_bytes; chain Dir::open_dir_at to reach arbitrary
depth.
Internally a Dir holds two fids, because the server rejects creates on an
already-opened fid: an unopened fid serves the *_at operations, and a
lazily opened sibling serves the listing cursor.
Implementations§
Source§impl Dir
impl Dir
Sourcepub async fn next_batch(
&self,
max_entries: Option<u32>,
) -> Result<Vec<DirEntry>, ZeroFsError>
pub async fn next_batch( &self, max_entries: Option<u32>, ) -> Result<Vec<DirEntry>, ZeroFsError>
Next batch of entries in directory order; None max returns one server
batch. An empty Vec means end of directory.
Sourcepub fn entries(self: &Arc<Dir>) -> DirStream
pub fn entries(self: &Arc<Dir>) -> DirStream
A futures_core::Stream of this directory’s entries, yielding them one
at a time (fetched a server batch at a time). Shares this Dir’s listing
cursor, so consuming the stream advances the same position as
Self::next_batch. Rust-only sugar (stream feature); never crosses FFI.
Sourcepub async fn rewind(&self) -> Result<(), ZeroFsError>
pub async fn rewind(&self) -> Result<(), ZeroFsError>
Restart iteration from the first entry.
Sourcepub async fn metadata(&self) -> Result<Metadata, ZeroFsError>
pub async fn metadata(&self) -> Result<Metadata, ZeroFsError>
Metadata for the directory itself.
Sourcepub async fn set_attr(&self, attrs: SetAttrs) -> Result<Metadata, ZeroFsError>
pub async fn set_attr(&self, attrs: SetAttrs) -> Result<Metadata, ZeroFsError>
Apply metadata changes to the directory itself (chmod/chown/utimens).
Sourcepub async fn open_at(
&self,
name: &[u8],
opts: OpenOptions,
) -> Result<Arc<File>, ZeroFsError>
pub async fn open_at( &self, name: &[u8], opts: OpenOptions, ) -> Result<Arc<File>, ZeroFsError>
openat(2)-alike: open (and optionally create) a child file.
Sourcepub async fn open_dir_at(&self, name: &[u8]) -> Result<Arc<Dir>, ZeroFsError>
pub async fn open_dir_at(&self, name: &[u8]) -> Result<Arc<Dir>, ZeroFsError>
Open a child directory (descend without UTF-8).
Sourcepub async fn metadata_at(&self, name: &[u8]) -> Result<Metadata, ZeroFsError>
pub async fn metadata_at(&self, name: &[u8]) -> Result<Metadata, ZeroFsError>
fstatat(2)-alike; never follows symlinks.
Sourcepub async fn set_attr_at(
&self,
name: &[u8],
attrs: SetAttrs,
) -> Result<Metadata, ZeroFsError>
pub async fn set_attr_at( &self, name: &[u8], attrs: SetAttrs, ) -> Result<Metadata, ZeroFsError>
Apply metadata changes to a child without opening it (works on symlinks, fifos, and non-UTF-8 names).
Sourcepub async fn create_dir_at(
&self,
name: &[u8],
mode: u32,
) -> Result<Metadata, ZeroFsError>
pub async fn create_dir_at( &self, name: &[u8], mode: u32, ) -> Result<Metadata, ZeroFsError>
mkdirat(2) with explicit mode; returns the new directory’s metadata.
Sourcepub async fn symlink_at(
&self,
name: &[u8],
target: &[u8],
) -> Result<Metadata, ZeroFsError>
pub async fn symlink_at( &self, name: &[u8], target: &[u8], ) -> Result<Metadata, ZeroFsError>
symlinkat(2): create child name containing raw byte target verbatim.
Sourcepub async fn link_at(
&self,
original_dir: &Dir,
original_name: &[u8],
new_name: &[u8],
) -> Result<Metadata, ZeroFsError>
pub async fn link_at( &self, original_dir: &Dir, original_name: &[u8], new_name: &[u8], ) -> Result<Metadata, ZeroFsError>
linkat(2): hard-link original_dir/original_name (any file type) as
self/new_name; returns metadata with the updated nlink.
Sourcepub async fn mknod_at(
&self,
name: &[u8],
kind: NodeKind,
mode: u32,
) -> Result<Metadata, ZeroFsError>
pub async fn mknod_at( &self, name: &[u8], kind: NodeKind, mode: u32, ) -> Result<Metadata, ZeroFsError>
mknodat(2): create a fifo, socket, or device node child.
Sourcepub async fn remove_file_at(&self, name: &[u8]) -> Result<(), ZeroFsError>
pub async fn remove_file_at(&self, name: &[u8]) -> Result<(), ZeroFsError>
unlinkat(2).
Sourcepub async fn remove_dir_at(&self, name: &[u8]) -> Result<(), ZeroFsError>
pub async fn remove_dir_at(&self, name: &[u8]) -> Result<(), ZeroFsError>
unlinkat(2) with AT_REMOVEDIR.
Sourcepub async fn rename_at(
&self,
old_name: &[u8],
new_dir: &Dir,
new_name: &[u8],
) -> Result<(), ZeroFsError>
pub async fn rename_at( &self, old_name: &[u8], new_dir: &Dir, new_name: &[u8], ) -> Result<(), ZeroFsError>
renameat(2) across two open directories (new_dir may be self).
Sourcepub async fn read_link_at(&self, name: &[u8]) -> Result<Vec<u8>, ZeroFsError>
pub async fn read_link_at(&self, name: &[u8]) -> Result<Vec<u8>, ZeroFsError>
readlinkat(2): raw target bytes.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Dir
impl !RefUnwindSafe for Dir
impl !UnwindSafe for Dir
impl Send for Dir
impl Sync for Dir
impl Unpin for Dir
impl UnsafeUnpin for Dir
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> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.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> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.