Skip to main content

PokeMap

Struct PokeMap 

Source
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>

Source

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() and def.v()

Violating these requirements can lead to memory safety issues.

Source

pub fn len(&self) -> usize

Get the number of entries in the map

Source

pub fn is_empty(&self) -> bool

Returns true if the map is empty

Source

pub fn contains_key( &self, key: &impl Facet<'facet>, ) -> Result<bool, ReflectError>

Check if the map contains a key

Source

pub fn contains_key_peek( &self, key: Peek<'_, 'facet>, ) -> Result<bool, ReflectError>

Check if the map contains a key (using a Peek)

Source

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

Source

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

Source

pub fn insert<K, V>(&mut self, key: K, value: V) -> Result<(), ReflectError>
where K: Facet<'facet>, V: Facet<'facet>,

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.

Source

pub fn insert_from_heap<const KB: bool, const VB: bool>( &mut self, key: HeapValue<'facet, KB>, value: HeapValue<'facet, VB>, ) -> Result<(), ReflectError>

Type-erased insert.

Accepts HeapValues for key and value; their shapes must match the map’s key and value types. Both values are moved into the map.

Source

pub fn iter(&self) -> PeekMapIter<'_, 'facet>

Returns an iterator over the key-value pairs in the map (read-only).

Source

pub const fn def(&self) -> MapDef

Def getter

Source

pub fn into_inner(self) -> Poke<'mem, 'facet>

Converts this PokeMap back into a Poke

Source

pub fn as_peek_map(&self) -> PeekMap<'_, 'facet>

Returns a read-only PeekMap view

Trait Implementations§

Source§

impl<'mem, 'facet> Debug for PokeMap<'mem, 'facet>

Source§

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

Formats the value using the given formatter. Read more

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> 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> 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, 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.