Trait Directory

Source
pub trait Directory: Node {
    // Required methods
    fn open(
        self: Arc<Self>,
        scope: ExecutionScope,
        flags: OpenFlags,
        path: Path,
        server_end: ServerEnd<NodeMarker>,
    );
    fn open3(
        self: Arc<Self>,
        scope: ExecutionScope,
        path: Path,
        flags: Flags,
        object_request: ObjectRequestRef<'_>,
    ) -> Result<(), Status>;
    fn read_dirents<'a>(
        &'a self,
        pos: &'a TraversalPosition,
        sink: Box<dyn Sink>,
    ) -> impl Future<Output = Result<(TraversalPosition, Box<dyn Sealed>), Status>> + Send
       where Self: Sized;
    fn register_watcher(
        self: Arc<Self>,
        scope: ExecutionScope,
        mask: WatchMask,
        watcher: DirectoryWatcher,
    ) -> Result<(), Status>;
    fn unregister_watcher(self: Arc<Self>, key: usize);

    // Provided method
    fn open3_async(
        self: Arc<Self>,
        scope: ExecutionScope,
        path: Path,
        flags: Flags,
        object_request: ObjectRequestRef<'_>,
    ) -> impl Future<Output = Result<(), Status>> + Send
       where Self: Sized { ... }
}
Expand description

All directories implement this trait. If a directory can be modified it should also implement the MutableDirectory trait.

Required Methods§

Source

fn open( self: Arc<Self>, scope: ExecutionScope, flags: OpenFlags, path: Path, server_end: ServerEnd<NodeMarker>, )

Opens a connection to this item if the path is “.” or a connection to an item inside this one otherwise. path will not contain any “.” or “..” components.

flags holds one or more of the OPEN_RIGHT_*, OPEN_FLAG_* constants. Processing of the flags value is specific to the item - in particular, the OPEN_RIGHT_* flags need to match the item capabilities.

It is the responsibility of the implementation to strip POSIX flags if the path crosses a boundary that does not have the required permissions.

It is the responsibility of the implementation to send an OnOpen event on the channel contained by server_end in case fio::OpenFlags::DESCRIBE` was set.

This method is called via either Open or Clone fuchsia.io methods. Any errors that occur during this process should be sent as a channel closure epitaph via server_end. No errors should ever affect the connection where Open or Clone were received.

Source

fn open3( self: Arc<Self>, scope: ExecutionScope, path: Path, flags: Flags, object_request: ObjectRequestRef<'_>, ) -> Result<(), Status>

Opens a connection to this item if the path is “.” or a connection to an item inside this one otherwise. path will not contain any “.” or “..” components.

flags corresponds to the fuchsia.io fio::Flags type. See fuchsia.io’s Open3 method for more information regarding how flags are handled and what flag combinations are valid.

If this method was initiated by a FIDL Open3 call, hierarchical rights are enforced at the connection layer.

If the implementation takes object_request, it is then responsible for sending an OnRepresentation event when flags includes fio::Flags::FLAG_SEND_REPRESENTATION.

This method is called via either Open3 or Reopen fuchsia.io methods. Any errors returned during this process will be sent via an epitaph on the object_request channel before closing the channel.

Source

fn read_dirents<'a>( &'a self, pos: &'a TraversalPosition, sink: Box<dyn Sink>, ) -> impl Future<Output = Result<(TraversalPosition, Box<dyn Sealed>), Status>> + Send
where Self: Sized,

Reads directory entries starting from pos by adding them to sink. Once finished, should return a sealed sink.

Source

fn register_watcher( self: Arc<Self>, scope: ExecutionScope, mask: WatchMask, watcher: DirectoryWatcher, ) -> Result<(), Status>

Register a watcher for this directory. Implementations will probably want to use a Watcher to manage watchers.

Source

fn unregister_watcher(self: Arc<Self>, key: usize)

Unregister a watcher from this directory. The watcher should no longer receive events.

Provided Methods§

Source

fn open3_async( self: Arc<Self>, scope: ExecutionScope, path: Path, flags: Flags, object_request: ObjectRequestRef<'_>, ) -> impl Future<Output = Result<(), Status>> + Send
where Self: Sized,

Same as open3 but the implementation is async. This may be more efficient if the directory needs to do async work to open the connection.

Implementors§

Source§

impl Directory for Simple

impl Directory for FatDirectory