Struct Simple

Source
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

Source

pub fn new() -> Arc<Self>

Source

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.

Source

pub fn get_entry(&self, name: &str) -> Result<Arc<dyn DirectoryEntry>, Status>

Returns the entry identified by name.

Source

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

Source

pub fn remove_all_entries(&self)

Removes all entries from the directory.

Trait Implementations§

Source§

impl DirectlyMutable for Simple

Source§

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>

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>
where NameT: Into<String>, Self: Sized,

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>
where NameT: Into<String>, Self: Sized,

Adds a child entry to this directory. If overwrite is true, this function may overwrite an existing entry. Read more
Source§

fn remove_entry<NameT>( &self, name: NameT, must_be_directory: bool, ) -> Result<Option<Arc<dyn DirectoryEntry>>, Status>
where NameT: Into<String>, Self: Sized,

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 more
Source§

impl Directory for Simple

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. Read more
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. Read more
Source§

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>

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.
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.
Source§

impl DirectoryEntry for Simple

Source§

fn open_entry(self: Arc<Self>, request: OpenRequest<'_>) -> Result<(), Status>

Opens this entry.
Source§

impl GetEntryInfo for Simple

Source§

fn entry_info(&self) -> EntryInfo

This method is used to populate ReadDirents() output.
Source§

impl Node for Simple

Source§

async fn get_attributes( &self, requested_attributes: NodeAttributesQuery, ) -> Result<NodeAttributes2, Status>

Returns node attributes (io2).
Source§

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)

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.
Source§

fn close(self: Arc<Self>)

Called when the node is closed.
Source§

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,

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> 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, D> Encode<Ambiguous1, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl<T, D> Encode<Ambiguous2, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoAny for T
where T: 'static + Send + Sync,

Source§

fn into_any(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Cast the given object into a dyn std::any::Any.
Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V