Map

Struct Map 

Source
pub struct Map<K, V> { /* private fields */ }
Expand description

A key-value map.

Implementations§

Source§

impl<K, V> Map<K, V>
where K: ObjectKey, V: ObjectValue,

Source

pub fn get<'a, 'b, L>( &self, ctx: &'a Context<'_>, key: L, ) -> Result<Option<<V as ObjectValue>::Out<'a>>, ClientError<u8>>
where L: Borrow<<K as ObjectValue>::In<'b>>,

Gets the value of the map at the given key.

Source

pub fn set<'a, L, U>( &self, ctx: &mut Context<'_>, key: L, value: U, ) -> Result<(), ClientError<u8>>
where L: Borrow<<K as ObjectValue>::In<'a>>, U: Borrow<<V as ObjectValue>::In<'a>>,

Sets the value of the map at the given key.

Source

pub fn delete<'a, L>( &self, ctx: &mut Context<'_>, key: L, ) -> Result<(), ClientError<u8>>
where L: Borrow<<K as ObjectValue>::In<'a>>,

Deletes the value of the map at the given key.

Trait Implementations§

Source§

impl<K, V> StateObjectResource for Map<K, V>

Source§

unsafe fn new(scope: &[u8], p: u8) -> Result<Map<K, V>, InitializationError>

Creates a new resource. This should only be called in generated code. Do not call this function directly.

Auto Trait Implementations§

§

impl<K, V> Freeze for Map<K, V>

§

impl<K, V> RefUnwindSafe for Map<K, V>

§

impl<K, V> Send for Map<K, V>
where K: Send, V: Send,

§

impl<K, V> Sync for Map<K, V>
where K: Sync, V: Sync,

§

impl<K, V> Unpin for Map<K, V>
where K: Unpin, V: Unpin,

§

impl<K, V> UnwindSafe for Map<K, V>
where K: UnwindSafe, V: UnwindSafe,

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.