pub struct Dir { /* private fields */ }Expand description
An open directory with a listing cursor and at-style child operations.
Child names are one byte-exact component without / or NUL. Use
DirEntry::name_bytes with the *_at methods for non-UTF-8 names.
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. Both
directories must belong to the same crate::Client.
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). Both
directories must belong to the same crate::Client.
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.