pub struct Simple { /* private fields */ }
Expand description
An implementation of a “simple” pseudo directory. This directory holds a set of entries,
allowing the server to add or remove entries via the
crate::directory::helper::DirectlyMutable::add_entry()
and
crate::directory::helper::DirectlyMutable::remove_entry
methods.
Implementations§
Source§impl Simple
impl Simple
pub fn new() -> Arc<Self>
Sourcepub fn set_not_found_handler(
self: Arc<Self>,
handler: Box<dyn FnMut(&str) + Send + Sync + 'static>,
)
pub fn set_not_found_handler( self: Arc<Self>, handler: Box<dyn FnMut(&str) + Send + Sync + 'static>, )
The provided function will be called whenever this VFS receives an open request for a path that is not present in the VFS. The function is invoked with the full path of the missing entry, relative to the root of this VFS. Typically this function is used for logging.
Sourcepub fn get_entry(&self, name: &str) -> Result<Arc<dyn DirectoryEntry>, Status>
pub fn get_entry(&self, name: &str) -> Result<Arc<dyn DirectoryEntry>, Status>
Returns the entry identified by name
.
Sourcepub fn get_or_insert<T: DirectoryEntry>(
&self,
name: Name,
f: impl FnOnce() -> Arc<T>,
) -> Arc<dyn DirectoryEntry>
pub fn get_or_insert<T: DirectoryEntry>( &self, name: Name, f: impl FnOnce() -> Arc<T>, ) -> Arc<dyn DirectoryEntry>
Gets or inserts an entry (as supplied by the callback f
).
Sourcepub fn remove_all_entries(&self)
pub fn remove_all_entries(&self)
Removes all entries from the directory.
Trait Implementations§
Source§impl DirectlyMutable for Simple
impl DirectlyMutable for Simple
Source§fn add_entry_impl(
&self,
name: Name,
entry: Arc<dyn DirectoryEntry>,
overwrite: bool,
) -> Result<(), AlreadyExists>
fn add_entry_impl( &self, name: Name, entry: Arc<dyn DirectoryEntry>, overwrite: bool, ) -> Result<(), AlreadyExists>
Adds a child entry to this directory.
Source§fn remove_entry_impl(
&self,
name: Name,
must_be_directory: bool,
) -> Result<Option<Arc<dyn DirectoryEntry>>, NotDirectory>
fn remove_entry_impl( &self, name: Name, must_be_directory: bool, ) -> Result<Option<Arc<dyn DirectoryEntry>>, NotDirectory>
Removes a child entry from this directory. In case an entry with the matching name was
found, the entry will be returned to the caller.
Source§fn add_entry<NameT>(
&self,
name: NameT,
entry: Arc<dyn DirectoryEntry>,
) -> Result<(), Status>
fn add_entry<NameT>( &self, name: NameT, entry: Arc<dyn DirectoryEntry>, ) -> Result<(), Status>
Adds a child entry to this directory. Read more
Source§fn add_entry_may_overwrite<NameT>(
&self,
name: NameT,
entry: Arc<dyn DirectoryEntry>,
overwrite: bool,
) -> Result<(), Status>
fn add_entry_may_overwrite<NameT>( &self, name: NameT, entry: Arc<dyn DirectoryEntry>, overwrite: bool, ) -> Result<(), Status>
Adds a child entry to this directory. If
overwrite
is true, this function may overwrite
an existing entry. Read moreSource§fn remove_entry<NameT>(
&self,
name: NameT,
must_be_directory: bool,
) -> Result<Option<Arc<dyn DirectoryEntry>>, Status>
fn remove_entry<NameT>( &self, name: NameT, must_be_directory: bool, ) -> Result<Option<Arc<dyn DirectoryEntry>>, Status>
Removes a child entry from this directory. In case an entry with the matching name was
found, the entry will be returned to the caller. If
must_be_directory
is true, an error
is returned if the entry is not a directory. Read moreSource§impl Directory for Simple
impl Directory for Simple
Source§fn open(
self: Arc<Self>,
scope: ExecutionScope,
flags: OpenFlags,
path: Path,
server_end: ServerEnd<NodeMarker>,
)
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. Read moreSource§fn open3(
self: Arc<Self>,
scope: ExecutionScope,
path: Path,
flags: Flags,
object_request: ObjectRequestRef<'_>,
) -> Result<(), Status>
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. Read moreSource§async fn read_dirents<'a>(
&'a self,
pos: &'a TraversalPosition,
sink: Box<dyn Sink>,
) -> Result<(TraversalPosition, Box<dyn Sealed>), Status>
async fn read_dirents<'a>( &'a self, pos: &'a TraversalPosition, sink: Box<dyn Sink>, ) -> Result<(TraversalPosition, Box<dyn Sealed>), Status>
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>
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)
fn unregister_watcher(self: Arc<Self>, key: usize)
Unregister a watcher from this directory. The watcher should no longer
receive events.
Source§fn open3_async(
self: Arc<Self>,
scope: ExecutionScope,
path: Path,
flags: Flags,
object_request: ObjectRequestRef<'_>,
) -> impl Future<Output = Result<(), Status>> + Sendwhere
Self: Sized,
fn open3_async(
self: Arc<Self>,
scope: ExecutionScope,
path: Path,
flags: Flags,
object_request: ObjectRequestRef<'_>,
) -> impl Future<Output = Result<(), Status>> + Sendwhere
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.Source§impl DirectoryEntry for Simple
impl DirectoryEntry for Simple
Source§fn open_entry(self: Arc<Self>, request: OpenRequest<'_>) -> Result<(), Status>
fn open_entry(self: Arc<Self>, request: OpenRequest<'_>) -> Result<(), Status>
Opens this entry.
Source§impl GetEntryInfo for Simple
impl GetEntryInfo for Simple
Source§fn entry_info(&self) -> EntryInfo
fn entry_info(&self) -> EntryInfo
This method is used to populate ReadDirents() output.
Source§impl Node for Simple
impl Node for Simple
Source§async fn get_attributes(
&self,
requested_attributes: NodeAttributesQuery,
) -> Result<NodeAttributes2, Status>
async fn get_attributes( &self, requested_attributes: NodeAttributesQuery, ) -> Result<NodeAttributes2, Status>
Returns node attributes (io2).
Source§fn will_open_as_node(&self) -> Result<(), Status>
fn will_open_as_node(&self) -> Result<(), Status>
Called when the node is about to be opened as the node protocol. Implementers can use this
to perform any initialization or reference counting. Errors here will result in the open
failing. By default, this forwards to the infallible will_clone.
Source§fn will_clone(&self)
fn will_clone(&self)
Called when the node is about to be cloned (and also by the default implementation of
will_open_as_node). Implementations that perform their own open count can use this. Each
call to
will_clone
will be accompanied by an eventual call to close
.fn link_into(
self: Arc<Self>,
_destination_dir: Arc<dyn MutableDirectory>,
_name: Name,
) -> impl Future<Output = Result<(), Status>> + Sendwhere
Self: Sized,
Source§fn query_filesystem(&self) -> Result<FilesystemInfo, Status>
fn query_filesystem(&self) -> Result<FilesystemInfo, Status>
Returns information about the filesystem.
Source§fn open_as_node(
self: Arc<Self>,
scope: ExecutionScope,
options: NodeOptions,
object_request: ObjectRequestRef<'_>,
) -> Result<(), Status>where
Self: Sized,
fn open_as_node(
self: Arc<Self>,
scope: ExecutionScope,
options: NodeOptions,
object_request: ObjectRequestRef<'_>,
) -> Result<(), Status>where
Self: Sized,
Opens the node using the node protocol.
Auto Trait Implementations§
impl !Freeze for Simple
impl RefUnwindSafe for Simple
impl Send for Simple
impl Sync for Simple
impl Unpin for Simple
impl UnwindSafe for Simple
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
Source§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more