pub struct Persisted<T> { /* private fields */ }Expand description
A wrapper for @persistent fields that auto-checkpoints on modification.
This provides interior mutability and automatic persistence when the
value is modified via set().
Implementations§
Source§impl<T: Clone + Serialize + DeserializeOwned + Default + Send> Persisted<T>
impl<T: Clone + Serialize + DeserializeOwned + Default + Send> Persisted<T>
Sourcepub fn new(
store: Arc<dyn CheckpointStore>,
agent_key: impl Into<String>,
field_name: impl Into<String>,
) -> Self
pub fn new( store: Arc<dyn CheckpointStore>, agent_key: impl Into<String>, field_name: impl Into<String>, ) -> Self
Create a new persisted field, loading from checkpoint if available.
Sourcepub fn with_initial(
store: Arc<dyn CheckpointStore>,
agent_key: impl Into<String>,
field_name: impl Into<String>,
initial: T,
) -> Self
pub fn with_initial( store: Arc<dyn CheckpointStore>, agent_key: impl Into<String>, field_name: impl Into<String>, initial: T, ) -> Self
Create with an explicit initial value (used when no checkpoint exists).
Sourcepub fn checkpoint(&self)
pub fn checkpoint(&self)
Checkpoint the current value without modifying it.
Auto Trait Implementations§
impl<T> !Freeze for Persisted<T>
impl<T> !RefUnwindSafe for Persisted<T>
impl<T> Send for Persisted<T>where
T: Send,
impl<T> Sync for Persisted<T>
impl<T> Unpin for Persisted<T>where
T: Unpin,
impl<T> UnsafeUnpin for Persisted<T>where
T: UnsafeUnpin,
impl<T> !UnwindSafe for Persisted<T>
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