Skip to main content

SyncIoDirectory

Trait SyncIoDirectory 

Source
pub trait SyncIoDirectory:
    Send
    + Sync
    + 'static {
    // Required methods
    fn seek(&self, new_index: u64) -> Result<u64, Status>;
    fn readdir<B, S: FnMut(u64, DirentType, &[u8]) -> ControlFlow<B, ()>>(
        &self,
        sink: S,
    ) -> Result<Option<B>, Status>;
    fn sync(&self) -> Result<(), Status>;
    fn clone_proxy(&self) -> Result<Option<DirectorySynchronousProxy>, Status>;
}
Expand description

A handle to an open directory connection for iterating over directory entries.

Readdir is a stateful operation, unlike all the other file and directory operations handled by SyncIo. Implementors of this trait need to manage that internal state, and users with different readdir positions each need to get their own SyncIoDirectory instance.

Required Methods§

Source

fn seek(&self, new_index: u64) -> Result<u64, Status>

Repositions the directory iterator for subsequent Self::readdir calls.

new_index is a 0-based entry count from the start of the directory. Returns the actual internal index.

Source

fn readdir<B, S: FnMut(u64, DirentType, &[u8]) -> ControlFlow<B, ()>>( &self, sink: S, ) -> Result<Option<B>, Status>

Reads entries from the current iterator position, calling the callback function on each entry.

Returning ControlFlow::Continue(()) from the callback consumes the entry and advances the index by 1. ControlFlow::Break(b) stops iteration without consuming the entry and returns Ok(Some(b)). Returns Ok(None) when no more entries remain.

Source

fn sync(&self) -> Result<(), Status>

Flushes pending directory updates to underlying storage.

Source

fn clone_proxy(&self) -> Result<Option<DirectorySynchronousProxy>, Status>

Clones the underlying FIDL directory connection if backed by one, or returns Ok(None) for in-process implementations. The cloned connection resets the position to zero.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§