pub unsafe trait StateClone<S> {
    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

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

Blanket implementation for all cloneable, flat types that don’t have references to items in the state.