pub trait PersistentField<'a, T>: Send + Syncwhere
    T: Serialize + Deserialize<'a>,{
    // Required methods
    fn set(&self, new_value: T);
    fn map<F, R>(&self, f: F) -> R
       where F: Fn(&T) -> R;
}
Expand description

Handles the functionality needed for persisting a non-parameter fields in a plugin’s state. These types can be used with Params#[persist = "..."] attributes.

This should be implemented for some type with interior mutability containing a T.

Required Methods§

source

fn set(&self, new_value: T)

Update the stored T value using interior mutability.

source

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&T) -> R,

Get a reference to the stored T value, and apply a function to it. This is used to serialize the T value.

Implementations on Foreign Types§

source§

impl<'a> PersistentField<'a, f32> for Arc<AtomicF32>

source§

fn set(&self, new_value: f32)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&f32) -> R,

source§

impl PersistentField<'_, u64> for AtomicU64

source§

fn set(&self, new_value: u64)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&u64) -> R,

source§

impl PersistentField<'_, i64> for AtomicI64

source§

fn set(&self, new_value: i64)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&i64) -> R,

source§

impl<'a, T> PersistentField<'a, T> for RwLock<T>where T: Serialize + Deserialize<'a> + Send + Sync,

source§

fn set(&self, new_value: T)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&T) -> R,

source§

impl PersistentField<'_, i16> for AtomicI16

source§

fn set(&self, new_value: i16)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&i16) -> R,

source§

impl<'a> PersistentField<'a, i64> for Arc<AtomicI64>

source§

fn set(&self, new_value: i64)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&i64) -> R,

source§

impl PersistentField<'_, u8> for AtomicU8

source§

fn set(&self, new_value: u8)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&u8) -> R,

source§

impl PersistentField<'_, bool> for AtomicBool

source§

fn set(&self, new_value: bool)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&bool) -> R,

source§

impl<'a> PersistentField<'a, isize> for Arc<AtomicIsize>

source§

fn set(&self, new_value: isize)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&isize) -> R,

source§

impl<'a, T> PersistentField<'a, T> for Arc<FairMutex<T>>where T: Serialize + Deserialize<'a> + Send + Sync,

source§

fn set(&self, new_value: T)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&T) -> R,

source§

impl<'a> PersistentField<'a, usize> for Arc<AtomicUsize>

source§

fn set(&self, new_value: usize)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&usize) -> R,

source§

impl PersistentField<'_, u32> for AtomicU32

source§

fn set(&self, new_value: u32)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&u32) -> R,

source§

impl<'a, T> PersistentField<'a, T> for Mutex<T>where T: Serialize + Deserialize<'a> + Send + Sync,

source§

fn set(&self, new_value: T)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&T) -> R,

source§

impl<'a> PersistentField<'a, i32> for Arc<AtomicI32>

source§

fn set(&self, new_value: i32)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&i32) -> R,

source§

impl<'a> PersistentField<'a, i16> for Arc<AtomicI16>

source§

fn set(&self, new_value: i16)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&i16) -> R,

source§

impl<'a> PersistentField<'a, u32> for Arc<AtomicU32>

source§

fn set(&self, new_value: u32)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&u32) -> R,

source§

impl<'a> PersistentField<'a, u8> for Arc<AtomicU8>

source§

fn set(&self, new_value: u8)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&u8) -> R,

source§

impl<'a, T> PersistentField<'a, T> for FairMutex<T>where T: Serialize + Deserialize<'a> + Send + Sync,

source§

fn set(&self, new_value: T)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&T) -> R,

source§

impl<'a, T> PersistentField<'a, T> for Arc<Mutex<T>>where T: Serialize + Deserialize<'a> + Send + Sync,

source§

fn set(&self, new_value: T)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&T) -> R,

source§

impl<'a, T> PersistentField<'a, T> for AtomicRefCell<T>where T: Serialize + Deserialize<'a> + Send + Sync,

source§

fn set(&self, new_value: T)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&T) -> R,

source§

impl<'a, T> PersistentField<'a, T> for RwLock<T>where T: Serialize + Deserialize<'a> + Send + Sync,

source§

fn set(&self, new_value: T)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&T) -> R,

source§

impl PersistentField<'_, u16> for AtomicU16

source§

fn set(&self, new_value: u16)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&u16) -> R,

source§

impl<'a, T> PersistentField<'a, T> for Mutex<T>where T: Serialize + Deserialize<'a> + Send + Sync,

source§

fn set(&self, new_value: T)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&T) -> R,

source§

impl PersistentField<'_, usize> for AtomicUsize

source§

fn set(&self, new_value: usize)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&usize) -> R,

source§

impl<'a> PersistentField<'a, u64> for Arc<AtomicU64>

source§

fn set(&self, new_value: u64)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&u64) -> R,

source§

impl PersistentField<'_, i32> for AtomicI32

source§

fn set(&self, new_value: i32)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&i32) -> R,

source§

impl<'a> PersistentField<'a, bool> for Arc<AtomicBool>

source§

fn set(&self, new_value: bool)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&bool) -> R,

source§

impl<'a, T> PersistentField<'a, T> for AtomicCell<T>where T: Serialize + Deserialize<'a> + Copy + Send,

source§

fn set(&self, new_value: T)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&T) -> R,

source§

impl<'a, T> PersistentField<'a, T> for Arc<AtomicRefCell<T>>where T: Serialize + Deserialize<'a> + Send + Sync,

source§

fn set(&self, new_value: T)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&T) -> R,

source§

impl<'a> PersistentField<'a, i8> for Arc<AtomicI8>

source§

fn set(&self, new_value: i8)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&i8) -> R,

source§

impl PersistentField<'_, f64> for AtomicF64

source§

fn set(&self, new_value: f64)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&f64) -> R,

source§

impl PersistentField<'_, isize> for AtomicIsize

source§

fn set(&self, new_value: isize)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&isize) -> R,

source§

impl<'a, T> PersistentField<'a, T> for Arc<RwLock<T>>where T: Serialize + Deserialize<'a> + Send + Sync,

source§

fn set(&self, new_value: T)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&T) -> R,

source§

impl<'a> PersistentField<'a, u16> for Arc<AtomicU16>

source§

fn set(&self, new_value: u16)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&u16) -> R,

source§

impl PersistentField<'_, i8> for AtomicI8

source§

fn set(&self, new_value: i8)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&i8) -> R,

source§

impl<'a> PersistentField<'a, f64> for Arc<AtomicF64>

source§

fn set(&self, new_value: f64)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&f64) -> R,

source§

impl<'a, T> PersistentField<'a, T> for Arc<AtomicCell<T>>where T: Serialize + Deserialize<'a> + Copy + Send,

source§

fn set(&self, new_value: T)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&T) -> R,

source§

impl<'a, T> PersistentField<'a, T> for Arc<RwLock<T>>where T: Serialize + Deserialize<'a> + Send + Sync,

source§

fn set(&self, new_value: T)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&T) -> R,

source§

impl<'a, T> PersistentField<'a, T> for Arc<Mutex<T>>where T: Serialize + Deserialize<'a> + Send + Sync,

source§

fn set(&self, new_value: T)

source§

fn map<F, R>(&self, f: F) -> Rwhere F: Fn(&T) -> R,

Implementors§