pub struct PkHashmapVariable { /* private fields */ }Expand description
A wrapper for std::collections::HashMap that implements the PkVariableAccessor trait.
Implementations§
Source§impl PkHashmapVariable
impl PkHashmapVariable
Sourcepub fn new(
init_vec: Vec<(String, Option<Vec<u8>>, Box<dyn Fn(Vec<u8>)>)>,
) -> Self
pub fn new( init_vec: Vec<(String, Option<Vec<u8>>, Box<dyn Fn(Vec<u8>)>)>, ) -> Self
Creates a new PkHashmapVariable instance.
§Arguments
init_vec: A vector of tuples, where each tuple contains:String: The variable key.Option<Vec<u8>>: The initial value of the variable. Defaults to an emptyVec<u8>ifNone.Box<dyn Fn(Vec<u8>) -> ()>: A listener function called when the variable is set.
IMPORTANT: The listener passed in here is synchronously executed and may block the main thread (where PkCommand::poll() is executed).
Use with caution or create a new thread if the listener is going to do something very costly.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PkHashmapVariable
impl !RefUnwindSafe for PkHashmapVariable
impl !Send for PkHashmapVariable
impl !Sync for PkHashmapVariable
impl Unpin for PkHashmapVariable
impl !UnwindSafe for PkHashmapVariable
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