Update documentation on PersistentField
This commit is contained in:
parent
7d4cafb33d
commit
fb0c1acbed
1 changed files with 10 additions and 4 deletions
|
@ -90,16 +90,22 @@ pub enum ParamPtr {
|
||||||
unsafe impl Send for ParamPtr {}
|
unsafe impl Send for ParamPtr {}
|
||||||
unsafe impl Sync for ParamPtr {}
|
unsafe impl Sync for ParamPtr {}
|
||||||
|
|
||||||
/// The functinoality needed for persisting a field to the plugin's state, and for restoring values
|
/// Handles the functionality needed for persisting a non-parameter fields in a plugin's state.
|
||||||
/// when loading old state.
|
/// These types can be used with [`Params`]' `#[persist = "..."]` attributes.
|
||||||
///
|
///
|
||||||
/// TODO: Modifying these fields (or any parameter for that matter) should mark the plugin's state
|
/// This should be implemented for some type with interior mutability containing a `T`.
|
||||||
/// as dirty.
|
//
|
||||||
|
// TODO: Modifying these fields (or any parameter for that matter) should mark the plugin's state
|
||||||
|
// as dirty.
|
||||||
pub trait PersistentField<'a, T>: Send + Sync
|
pub trait PersistentField<'a, T>: Send + Sync
|
||||||
where
|
where
|
||||||
T: serde::Serialize + serde::Deserialize<'a>,
|
T: serde::Serialize + serde::Deserialize<'a>,
|
||||||
{
|
{
|
||||||
|
/// Update the stored `T` value using interior mutability.
|
||||||
fn set(&self, new_value: T);
|
fn set(&self, new_value: T);
|
||||||
|
|
||||||
|
/// Get a reference to the stored `T` value, and apply a function to it. This is used to
|
||||||
|
/// serialize the `T` value.
|
||||||
fn map<F, R>(&self, f: F) -> R
|
fn map<F, R>(&self, f: F) -> R
|
||||||
where
|
where
|
||||||
F: Fn(&T) -> R;
|
F: Fn(&T) -> R;
|
||||||
|
|
Loading…
Add table
Reference in a new issue