Skip to main content

Dir

Struct Dir 

Source
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

Source

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.

Source

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.

Source

pub async fn rewind(&self) -> Result<(), ZeroFsError>

Restart iteration from the first entry.

Source

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

Metadata for the directory itself.

Source

pub async fn set_attr(&self, attrs: SetAttrs) -> Result<Metadata, ZeroFsError>

Apply metadata changes to the directory itself (chmod/chown/utimens).

Source

pub async fn open_at( &self, name: &[u8], opts: OpenOptions, ) -> Result<Arc<File>, ZeroFsError>

openat(2)-alike: open (and optionally create) a child file.

Source

pub async fn open_dir_at(&self, name: &[u8]) -> Result<Arc<Dir>, ZeroFsError>

Open a child directory (descend without UTF-8).

Source

pub async fn metadata_at(&self, name: &[u8]) -> Result<Metadata, ZeroFsError>

fstatat(2)-alike; never follows symlinks.

Source

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

Source

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.

symlinkat(2): create child name containing raw byte target verbatim.

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.

Source

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.

Source

pub async fn remove_file_at(&self, name: &[u8]) -> Result<(), ZeroFsError>

unlinkat(2).

Source

pub async fn remove_dir_at(&self, name: &[u8]) -> Result<(), ZeroFsError>

unlinkat(2) with AT_REMOVEDIR.

Source

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.

readlinkat(2): raw target bytes.

Source

pub async fn close(&self)

Marks the handle closed. Drop schedules both fids for release. This call is idempotent and non-blocking.

Trait Implementations§

Source§

impl Debug for Dir

Source§

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

Formats the value using the given formatter. Read more

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> 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> 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, 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