pub struct PluginStateMap { /* private fields */ }Expand description
Type-keyed map for plugin state with serialization support.
Provides type-safe access keyed by PluginStateKey implementations.
Plugins cannot access each other’s state — the type key enforces isolation.
Implementations§
Source§impl PluginStateMap
impl PluginStateMap
Sourcepub fn register<P>(
&mut self,
state: P::State,
) -> Result<PluginHandle<P>, &'static str>
pub fn register<P>( &mut self, state: P::State, ) -> Result<PluginHandle<P>, &'static str>
Register plugin state, returning a proof handle.
§Errors
Returns the key string if a plugin with the same TypeId is already registered.
Sourcepub fn get<P: PluginStateKey>(&self) -> Option<&P::State>
pub fn get<P: PluginStateKey>(&self) -> Option<&P::State>
Get an immutable reference to plugin state.
Sourcepub fn get_mut<P: PluginStateKey>(&mut self) -> Option<&mut P::State>
pub fn get_mut<P: PluginStateKey>(&mut self) -> Option<&mut P::State>
Get a mutable reference to plugin state.
Sourcepub fn insert<P: PluginStateKey>(&mut self, state: P::State)
pub fn insert<P: PluginStateKey>(&mut self, state: P::State)
Insert or replace plugin state.
Sourcepub fn serialize_all(&self) -> Value
pub fn serialize_all(&self) -> Value
Serialize all plugin state to a JSON object keyed by plugin key strings.
Trait Implementations§
Source§impl Debug for PluginStateMap
impl Debug for PluginStateMap
Source§impl Default for PluginStateMap
impl Default for PluginStateMap
Source§fn default() -> PluginStateMap
fn default() -> PluginStateMap
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for PluginStateMap
impl !RefUnwindSafe for PluginStateMap
impl Send for PluginStateMap
impl Sync for PluginStateMap
impl Unpin for PluginStateMap
impl UnsafeUnpin for PluginStateMap
impl !UnwindSafe for PluginStateMap
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