pub struct PluginState { /* private fields */ }Expand description
A plugin’s persistable state: parameter values plus opaque keyed data.
Parameters are keyed by their numeric id and opaque data by string key, both
in sorted BTreeMaps so serialization is deterministic. The state
round-trips through an Expr map via PluginState::to_expr and
PluginState::from_expr.
Implementations§
Source§impl PluginState
impl PluginState
Sourcepub fn set_param(&mut self, id: u32, value: f64)
pub fn set_param(&mut self, id: u32, value: f64)
Sets the value of the parameter with the given id, inserting it if absent.
Sourcepub fn param(&self, id: u32) -> Option<f64>
pub fn param(&self, id: u32) -> Option<f64>
Returns the stored value for the parameter id, if present.
Sourcepub fn insert_data(&mut self, key: impl Into<String>, value: Expr)
pub fn insert_data(&mut self, key: impl Into<String>, value: Expr)
Inserts or replaces an opaque data entry under key.
Sourcepub fn to_expr(&self) -> Expr
pub fn to_expr(&self) -> Expr
Encodes the state as a tagged Expr map.
The result is a plugin-core/state-tagged map carrying params and
data vectors; PluginState::from_expr reverses it.
Trait Implementations§
Source§impl Clone for PluginState
impl Clone for PluginState
Source§fn clone(&self) -> PluginState
fn clone(&self) -> PluginState
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PluginState
impl Debug for PluginState
Source§impl Default for PluginState
impl Default for PluginState
Source§fn default() -> PluginState
fn default() -> PluginState
Returns the “default value” for a type. Read more
Source§impl PartialEq for PluginState
impl PartialEq for PluginState
Source§fn eq(&self, other: &PluginState) -> bool
fn eq(&self, other: &PluginState) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for PluginState
Auto Trait Implementations§
impl Freeze for PluginState
impl RefUnwindSafe for PluginState
impl Send for PluginState
impl Sync for PluginState
impl Unpin for PluginState
impl UnsafeUnpin for PluginState
impl UnwindSafe for PluginState
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