pub struct EnvelopeMut<'a> { /* private fields */ }Expand description
A mutably borrowed reflected value with read + write capability access.
Created by reflect_mut! or Envelope::as_mut. Analogous to &mut [T].
Provides mutable access to capabilities without consuming the original value.
§Example
let mut value = Counter { count: 42 };
let mut envelope_mut = reflect_mut!(&mut value);
envelope_mut.get_mut::<ResettableCap>().unwrap().reset();
assert_eq!(value.count, 0);Implementations§
Source§impl<'a> EnvelopeMut<'a>
impl<'a> EnvelopeMut<'a>
pub fn from_parts(data: &'a mut dyn Any, caps: CapabilityMap) -> Self
Sourcepub fn caps(&self) -> &CapabilityMap
pub fn caps(&self) -> &CapabilityMap
Get a shared reference to the capability map.
Sourcepub fn as_ref(&self) -> EnvelopeRef<'_>
pub fn as_ref(&self) -> EnvelopeRef<'_>
Downgrade to a read-only EnvelopeRef.
Sourcepub fn get<C: Capability>(&self) -> Option<&C::Handle>
pub fn get<C: Capability>(&self) -> Option<&C::Handle>
Get a shared reference to the capability’s trait object.
Returns None if the wrapped type doesn’t implement the capability’s trait bound.
Sourcepub fn get_mut<C: Capability>(&mut self) -> Option<&mut C::Handle>
pub fn get_mut<C: Capability>(&mut self) -> Option<&mut C::Handle>
Get a mutable reference to the capability’s trait object.
Returns None if the wrapped type doesn’t implement the capability’s trait bound.
Sourcepub fn has<C: Capability>(&self) -> bool
pub fn has<C: Capability>(&self) -> bool
Check whether this envelope’s value has a given capability.
Sourcepub fn data<T: 'static>(&self) -> Option<&T>
pub fn data<T: 'static>(&self) -> Option<&T>
Get a shared reference to the underlying concrete type.
Returns None if T doesn’t match the actual stored type.
Sourcepub fn data_mut<T: 'static>(&mut self) -> Option<&mut T>
pub fn data_mut<T: 'static>(&mut self) -> Option<&mut T>
Get a mutable reference to the underlying concrete type.
Returns None if T doesn’t match the actual stored type.
Sourcepub fn capability_count(&self) -> usize
pub fn capability_count(&self) -> usize
The number of capabilities detected on this value.