pub struct Dictionary { /* private fields */ }Expand description
A capability that represents a dictionary of capabilities.
Implementations§
Source§impl Dictionary
impl Dictionary
Sourcepub fn new_with_not_found(
not_found: impl Fn(&str) + 'static + Send + Sync,
) -> Self
pub fn new_with_not_found( not_found: impl Fn(&str) + 'static + Send + Sync, ) -> Self
Creates an empty dictionary. When an external request tries to access a non-existent entry,
the name of the entry will be sent using not_found.
Sourcepub fn register_update_notifier(&self, notifier_fn: UpdateNotifierFn)
pub fn register_update_notifier(&self, notifier_fn: UpdateNotifierFn)
Registers a new update notifier function with this dictionary. The function will be called
whenever an entry is added to or removed from this dictionary. The function will be
immediately called with an EntryUpdate::Add value for any entries already in this
dictionary.
Note that this function will be called while the internal dictionary structure is locked, so it must not interact with the dictionary on which it is registered. It shouldn’t even hold a strong reference to the dictionary it’s registered on, as that’ll create a cycle and make LSAN sad.
Sourcepub fn insert(
&self,
key: Key,
capability: Capability,
) -> Result<(), CapabilityStoreError>
pub fn insert( &self, key: Key, capability: Capability, ) -> Result<(), CapabilityStoreError>
Inserts an entry, mapping key to capability. If an entry already exists at key, a
fsandbox::DictionaryError::AlreadyExists will be returned.
pub fn append(&self, other: &Dictionary) -> Result<(), ()>
Sourcepub fn get<Q>(&self, key: &Q) -> Option<Capability>
pub fn get<Q>(&self, key: &Q) -> Option<Capability>
Returns a clone of the capability associated with key. If there is no entry for key,
None is returned.
Sourcepub fn get_or_insert(
&self,
key: &Key,
default: impl FnOnce() -> Capability,
) -> Capability
pub fn get_or_insert( &self, key: &Key, default: impl FnOnce() -> Capability, ) -> Capability
Returns a clone of the capability associated with key, or populates it with default if
it is not present.
Sourcepub fn remove(&self, key: &BorrowedName) -> Option<Capability>
pub fn remove(&self, key: &BorrowedName) -> Option<Capability>
Removes key from the entries, returning the capability at key if the key was already in
the entries.
Sourcepub fn enumerate(&self) -> impl Iterator<Item = (Key, Capability)> + use<>
pub fn enumerate(&self) -> impl Iterator<Item = (Key, Capability)> + use<>
Returns an iterator over a clone of the entries, sorted by key.
Sourcepub fn snapshot_keys_as_strings(&self) -> Vec<String>
pub fn snapshot_keys_as_strings(&self) -> Vec<String>
Returns the keys.
Sourcepub fn drain(&self) -> impl Iterator<Item = (Key, Capability)> + use<>
pub fn drain(&self) -> impl Iterator<Item = (Key, Capability)> + use<>
Removes all entries from the Dictionary and returns them as an iterator.
Sourcepub fn shallow_copy(&self) -> Result<Self, ()>
pub fn shallow_copy(&self) -> Result<Self, ()>
Creates a new Dictionary with entries cloned from this Dictionary.
This is a shallow copy. Values are cloned, not copied, so are new references to the same underlying data.
If any value in the dictionary could not be cloned, returns an error.
Source§impl Dictionary
impl Dictionary
Sourcepub fn try_into_directory_entry_oneshot(
self,
scope: ExecutionScope,
token: WeakInstanceToken,
) -> Result<Arc<dyn DirectoryEntry>, ConversionError>
pub fn try_into_directory_entry_oneshot( self, scope: ExecutionScope, token: WeakInstanceToken, ) -> Result<Arc<dyn DirectoryEntry>, ConversionError>
Like RemotableCapability::try_into_directory_entry, but this version actually consumes
the contents of the Dictionary. In other words, if this function returns Ok, self
will be empty. If any items are added to self later, they will not appear in the
directory. This method is useful when the caller has no need to keep the original
Dictionary. Note that even if there is only one reference to the Dictionary, calling
RemotableCapability::try_into_directory_entry does not have the same effect because the
vfs keeps alive reference to the Dictionary – see the comment in the implementation.
This is transitive: any Dictionarys nested in this one will be consumed as well.
Trait Implementations§
Source§impl CapabilityBound for Dictionary
impl CapabilityBound for Dictionary
fn debug_typename() -> &'static str
Source§impl Clone for Dictionary
impl Clone for Dictionary
Source§fn clone(&self) -> Dictionary
fn clone(&self) -> Dictionary
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Dictionary
impl Debug for Dictionary
Source§impl Default for Dictionary
impl Default for Dictionary
Source§impl From<Dictionary> for Capability
impl From<Dictionary> for Capability
Source§fn from(f: Dictionary) -> Self
fn from(f: Dictionary) -> Self
Source§impl From<Dictionary> for DictionaryRef
impl From<Dictionary> for DictionaryRef
Source§fn from(dict: Dictionary) -> Self
fn from(dict: Dictionary) -> Self
Source§impl FromEnum<Capability> for Dictionary
impl FromEnum<Capability> for Dictionary
fn from_enum(e: &Capability) -> Option<&Self>
Source§impl IntoFsandboxCapability for Dictionary
impl IntoFsandboxCapability for Dictionary
fn into_fsandbox_capability(self, _token: WeakInstanceToken) -> Capability
Source§impl RemotableCapability for Dictionary
impl RemotableCapability for Dictionary
Source§fn try_into_directory_entry(
self,
scope: ExecutionScope,
token: WeakInstanceToken,
) -> Result<Arc<dyn DirectoryEntry>, ConversionError>
fn try_into_directory_entry( self, scope: ExecutionScope, token: WeakInstanceToken, ) -> Result<Arc<dyn DirectoryEntry>, ConversionError>
self to a DirectoryEntry which can be served in a VFS. If routing
needs to be performed, token should be the WeakInstanceToken used for the route. Read moreSource§impl TryFrom<Capability> for Dictionary
impl TryFrom<Capability> for Dictionary
Source§impl TryFrom<Channel> for Dictionary
impl TryFrom<Channel> for Dictionary
Source§impl TryFrom<DictionaryRef> for Dictionary
impl TryFrom<DictionaryRef> for Dictionary
Source§type Error = RemoteError
type Error = RemoteError
Auto Trait Implementations§
impl Freeze for Dictionary
impl !RefUnwindSafe for Dictionary
impl Send for Dictionary
impl Sync for Dictionary
impl Unpin for Dictionary
impl UnsafeUnpin for Dictionary
impl !UnwindSafe for Dictionary
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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