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§

source

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.

source

fn apply_mut(&self, to: &mut Data)

Apply the update a cloned new instance of Versioned.data.

After updating it, to will replace the data in Versioned.

Provided Methods§

source

fn apply(&self, to: &mut Versioned<Data>)

Try to apply an update Versioned.data in place if possible and return. Or replace Versioned.data with a new one. Finally it increments the Versioned.version by 1 to indicate the data has changed.

Implementors§