pub trait Update<Data>where
Data: Clone,{
// Required methods
fn apply_in_place(&self, to: &Arc<Data>) -> Result<(), UpdateError>;
fn apply_mut(&self, to: &mut Data);
// Provided method
fn apply(&self, to: &mut Versioned<Data>) { ... }
}
Expand description
Defines an update operation that can be applied to Versioned<Data>
The update try to update Versioned.data
in place if possible.
If in place update can not be done, it then update it by replacing Versioned.data
with a new
cloned instance.
A user needs to implement two update methods: update_in_place()
and update_mut()
.
Required Methods§
sourcefn apply_in_place(&self, to: &Arc<Data>) -> Result<(), UpdateError>
fn apply_in_place(&self, to: &Arc<Data>) -> Result<(), UpdateError>
Apply the update to the Versioned.data
in place if possible.
If it can not be done, it should return an error to inform it to update the Versioned.data
by replacing it.