Trait concordium_std::StateClone
source · pub unsafe trait StateClone<S> {
// Required method
unsafe fn clone_state(&self, cloned_state_api: &S) -> Self;
}
Expand description
Types that can be cloned along with the state.
Used for rolling back the test state when errors occur in a receive
function. See TestHost::with_rollback
and
TestHost::invoke_contract_raw
.
Safety
Marked unsafe because special care should be taken when
implementing this trait. In particular, one should only use the supplied
cloned_state_api
, or (shallow) clones thereof. Creating a new
HasStateApi
or using a deep_clone
will lead to an inconsistent state
and undefined behaviour.
Required Methods§
sourceunsafe fn clone_state(&self, cloned_state_api: &S) -> Self
unsafe fn clone_state(&self, cloned_state_api: &S) -> Self
Make a clone of the type while using the cloned_state_api
.
Safety
Marked unsafe because this function should not be called directly. It is only used within generated code and in the test infrastructure.
Implementors§
impl<T, S: HasStateApi> StateClone<S> for StateSet<T, S>
impl<T, V, S: HasStateApi> StateClone<S> for StateMap<T, V, S>
impl<T: Clone, S> StateClone<S> for T
Blanket implementation for all cloneable, flat types that don’t have references to items in the state.