pub struct PokeMap<'mem, 'facet> { /* private fields */ }Expand description
Lets you mutate a map (implements mutable facet_core::MapVTable proxies)
Implementations§
Source§impl<'mem, 'facet> PokeMap<'mem, 'facet>
impl<'mem, 'facet> PokeMap<'mem, 'facet>
Sourcepub const unsafe fn new(value: Poke<'mem, 'facet>, def: MapDef) -> Self
pub const unsafe fn new(value: Poke<'mem, 'facet>, def: MapDef) -> Self
Creates a new poke map
§Safety
The caller must ensure that def contains valid vtable function pointers that:
- Correctly implement the map operations for the actual type
- Do not cause undefined behavior when called
- Return pointers within valid memory bounds
- Match the key and value types specified in
def.k()anddef.v()
Violating these requirements can lead to memory safety issues.
Sourcepub fn contains_key(
&self,
key: &impl Facet<'facet>,
) -> Result<bool, ReflectError>
pub fn contains_key( &self, key: &impl Facet<'facet>, ) -> Result<bool, ReflectError>
Check if the map contains a key
Sourcepub fn contains_key_peek(
&self,
key: Peek<'_, 'facet>,
) -> Result<bool, ReflectError>
pub fn contains_key_peek( &self, key: Peek<'_, 'facet>, ) -> Result<bool, ReflectError>
Check if the map contains a key (using a Peek)
Sourcepub fn get(
&self,
key: &impl Facet<'facet>,
) -> Result<Option<Peek<'_, 'facet>>, ReflectError>
pub fn get( &self, key: &impl Facet<'facet>, ) -> Result<Option<Peek<'_, 'facet>>, ReflectError>
Get a value from the map for the given key, as a read-only Peek
Sourcepub fn get_peek(
&self,
key: Peek<'_, 'facet>,
) -> Result<Option<Peek<'_, 'facet>>, ReflectError>
pub fn get_peek( &self, key: Peek<'_, 'facet>, ) -> Result<Option<Peek<'_, 'facet>>, ReflectError>
Get a value from the map for the given key (using a Peek), as a read-only Peek
Sourcepub fn insert<K, V>(&mut self, key: K, value: V) -> Result<(), ReflectError>
pub fn insert<K, V>(&mut self, key: K, value: V) -> Result<(), ReflectError>
Insert a key-value pair into the map.
Both key and value must have shapes matching the map’s key and value types. The key and value are moved into the map.
Sourcepub fn insert_from_heap<const KB: bool, const VB: bool>(
&mut self,
key: HeapValue<'facet, KB>,
value: HeapValue<'facet, VB>,
) -> Result<(), ReflectError>
pub fn insert_from_heap<const KB: bool, const VB: bool>( &mut self, key: HeapValue<'facet, KB>, value: HeapValue<'facet, VB>, ) -> Result<(), ReflectError>
Sourcepub fn iter(&self) -> PeekMapIter<'_, 'facet> ⓘ
pub fn iter(&self) -> PeekMapIter<'_, 'facet> ⓘ
Returns an iterator over the key-value pairs in the map (read-only).
Sourcepub fn into_inner(self) -> Poke<'mem, 'facet>
pub fn into_inner(self) -> Poke<'mem, 'facet>
Converts this PokeMap back into a Poke
Sourcepub fn as_peek_map(&self) -> PeekMap<'_, 'facet>
pub fn as_peek_map(&self) -> PeekMap<'_, 'facet>
Returns a read-only PeekMap view
Trait Implementations§
Auto Trait Implementations§
impl<'mem, 'facet> Freeze for PokeMap<'mem, 'facet>
impl<'mem, 'facet> RefUnwindSafe for PokeMap<'mem, 'facet>
impl<'mem, 'facet> !Send for PokeMap<'mem, 'facet>
impl<'mem, 'facet> !Sync for PokeMap<'mem, 'facet>
impl<'mem, 'facet> Unpin for PokeMap<'mem, 'facet>
impl<'mem, 'facet> UnsafeUnpin for PokeMap<'mem, 'facet>
impl<'mem, 'facet> !UnwindSafe for PokeMap<'mem, 'facet>
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
Mutably borrows from an owned value. Read more