Dict

Struct Dict 

Source
pub struct Dict { /* private fields */ }
Expand description

A capability that represents a dictionary of capabilities.

Implementations§

Source§

impl Dict

Source

pub fn new() -> Self

Creates an empty dictionary.

Source

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.

Source

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.

Source

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.

Source

pub fn append(&self, other: &Dict) -> Result<(), ()>

Source

pub fn get<Q>(&self, key: &Q) -> Result<Option<Capability>, ()>
where Key: Borrow<Q> + Ord, Q: Ord + ?Sized,

Returns a clone of the capability associated with key. If there is no entry for key, None is returned.

If the value could not be cloned, returns an error.

Source

pub fn get_or_insert( &self, key: &Key, default: impl FnOnce() -> Capability, ) -> Result<Capability, ()>

Returns a clone of the capability associated with key, or populates it with default if it is not present.

If the value could not be cloned, returns an error.

Source

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.

Source

pub fn enumerate( &self, ) -> impl Iterator<Item = (Key, Result<Capability, ()>)> + use<>

Returns an iterator over a clone of the entries, sorted by key.

If a capability is not cloneable, an error returned for the value.

Source

pub fn keys(&self) -> impl Iterator<Item = Key> + use<>

Returns an iterator over the keys, in sorted order.

Source

pub fn drain(&self) -> impl Iterator<Item = (Key, Capability)> + use<>

Removes all entries from the Dict and returns them as an iterator.

Source

pub fn shallow_copy(&self) -> Result<Self, ()>

Creates a new Dict with entries cloned from this Dict.

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 Dict

Source

pub fn try_into_directory_entry_oneshot( self, scope: ExecutionScope, ) -> Result<Arc<dyn DirectoryEntry>, ConversionError>

Like RemotableCapability::try_into_directory_entry, but this version actually consumes the contents of the Dict. 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 Dict. Note that even if there is only one reference to the Dict, calling RemotableCapability::try_into_directory_entry does not have the same effect because the vfs keeps alive reference to the Dict – see the comment in the implementation.

This is transitive: any Dicts nested in this one will be consumed as well.

Trait Implementations§

Source§

impl CapabilityBound for Dict

Source§

fn debug_typename() -> &'static str

Source§

impl Clone for Dict

Source§

fn clone(&self) -> Dict

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Dict

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Dict

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<Dict> for Capability

Source§

fn from(f: Dict) -> Self

Converts to this type from the input type.
Source§

impl From<Dict> for Capability

Source§

fn from(dict: Dict) -> Self

Converts to this type from the input type.
Source§

impl From<Dict> for DictionaryRef

Source§

fn from(dict: Dict) -> Self

Converts to this type from the input type.
Source§

impl FromEnum<Capability> for Dict

Source§

impl RemotableCapability for Dict

Source§

fn try_into_directory_entry( self, scope: ExecutionScope, ) -> Result<Arc<dyn DirectoryEntry>, ConversionError>

Attempt to convert self to a DirectoryEntry which can be served in a VFS. Read more
Source§

impl TryFrom<Capability> for Dict

Source§

type Error = ()

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

fn try_from(c: Capability) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Channel> for Dict

Source§

type Error = RemoteError

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

fn try_from(dict: Channel) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<DictionaryRef> for Dict

Source§

type Error = RemoteError

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

fn try_from(dict: DictionaryRef) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl Freeze for Dict

§

impl RefUnwindSafe for Dict

§

impl Send for Dict

§

impl Sync for Dict

§

impl Unpin for Dict

§

impl UnwindSafe for Dict

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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 + Send + Sync>

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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