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,
) -> Arc<Self> ⓘ
pub fn new_with_not_found( not_found: impl Fn(&str) + 'static + Send + Sync, ) -> Arc<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) -> Option<Capability>
pub fn insert(&self, key: Key, capability: Capability) -> Option<Capability>
Inserts an entry, mapping key to capability. If an entry already exists at key, the
old value 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) -> Arc<Self> ⓘ
pub fn shallow_copy(&self) -> Arc<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.
Source§impl Dictionary
impl Dictionary
pub fn from_channel(dict: Channel) -> Result<Arc<Self>, RemoteError>
pub fn try_from_fsandbox( dictionary: DictionaryRef, ) -> Result<Arc<Self>, RemoteError>
pub fn to_fsandbox(self: Arc<Self>) -> DictionaryRef
Sourcepub fn try_into_directory_entry_oneshot(
self: Arc<Self>,
scope: ExecutionScope,
token: Arc<WeakInstanceToken>,
) -> Result<Arc<dyn DirectoryEntry>, ConversionError>
pub fn try_into_directory_entry_oneshot( self: Arc<Self>, scope: ExecutionScope, token: Arc<WeakInstanceToken>, ) -> Result<Arc<dyn DirectoryEntry>, ConversionError>
Like [CapabilityBound::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
[CapabilityBound::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§fn try_into_directory_entry(
self: Arc<Self>,
scope: ExecutionScope,
token: Arc<WeakInstanceToken>,
) -> Result<Arc<dyn DirectoryEntry>, ConversionError>
fn try_into_directory_entry( self: Arc<Self>, scope: ExecutionScope, token: Arc<WeakInstanceToken>, ) -> Result<Arc<dyn DirectoryEntry>, ConversionError>
Source§impl Debug for Dictionary
impl Debug for Dictionary
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, 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,
§impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
fn fidl_into_native(self) -> Box<N>
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