pub trait Directory: Node {
// Required methods
fn open(
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 methods
fn open_async(
self: Arc<Self>,
scope: ExecutionScope,
path: Path,
flags: Flags,
object_request: ObjectRequestRef<'_>,
) -> impl Future<Output = Result<(), Status>> + Send
where Self: Sized { ... }
fn deprecated_open(
self: Arc<Self>,
_scope: ExecutionScope,
flags: OpenFlags,
_path: Path,
server_end: ServerEnd<NodeMarker>,
) { ... }
}
Expand description
All directories implement this trait. If a directory can be modified it should
also implement the MutableDirectory
trait.
Required Methods§
Sourcefn open(
self: Arc<Self>,
scope: ExecutionScope,
path: Path,
flags: Flags,
object_request: ObjectRequestRef<'_>,
) -> Result<(), Status>
fn open( 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 Open method for
more information regarding how flags are handled and what flag combinations are valid.
If this method was initiated by a FIDL Open 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 Open
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.
Sourcefn read_dirents<'a>(
&'a self,
pos: &'a TraversalPosition,
sink: Box<dyn Sink>,
) -> impl Future<Output = Result<(TraversalPosition, Box<dyn Sealed>), Status>> + Sendwhere
Self: Sized,
fn read_dirents<'a>(
&'a self,
pos: &'a TraversalPosition,
sink: Box<dyn Sink>,
) -> impl Future<Output = Result<(TraversalPosition, Box<dyn Sealed>), Status>> + Sendwhere
Self: Sized,
Reads directory entries starting from pos
by adding them to sink
.
Once finished, should return a sealed sink.
Sourcefn register_watcher(
self: Arc<Self>,
scope: ExecutionScope,
mask: WatchMask,
watcher: DirectoryWatcher,
) -> Result<(), Status>
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.
Sourcefn unregister_watcher(self: Arc<Self>, key: usize)
fn unregister_watcher(self: Arc<Self>, key: usize)
Unregister a watcher from this directory. The watcher should no longer receive events.
Provided Methods§
Sourcefn open_async(
self: Arc<Self>,
scope: ExecutionScope,
path: Path,
flags: Flags,
object_request: ObjectRequestRef<'_>,
) -> impl Future<Output = Result<(), Status>> + Sendwhere
Self: Sized,
fn open_async(
self: Arc<Self>,
scope: ExecutionScope,
path: Path,
flags: Flags,
object_request: ObjectRequestRef<'_>,
) -> impl Future<Output = Result<(), Status>> + Sendwhere
Self: Sized,
Same as Self::open
but the implementation is async. This may be more efficient if the
directory needs to do async work to open the connection.
Sourcefn deprecated_open(
self: Arc<Self>,
_scope: ExecutionScope,
flags: OpenFlags,
_path: Path,
server_end: ServerEnd<NodeMarker>,
)
fn deprecated_open( self: Arc<Self>, _scope: ExecutionScope, flags: OpenFlags, _path: Path, server_end: ServerEnd<NodeMarker>, )
DEPRECATED - Do not implement unless required for backwards compatibility. Called when handling a fuchsia.io/Directory.DeprecatedOpen request.