Derive Macro concordium_std::StateClone

source ·
#[derive(StateClone)]
{
    // Attributes available to this derive:
    #[concordium]
}
Expand description

Derive the StateClone trait. See the documentation of derive(StateClone) for details and limitations.

The trait is used in the TestHost when rolling back the state. If that functionality is needed, then this trait must be derived for types which have not implement the Clone trait. That is, StateClone should be derived for types with a non-trivial state. Non-trivial state here means when you have a type MyState which has one or more fields comprised of StateBox, StateSet, or StateMap.

Please note that it is necessary to specify the generic parameter name for the HasStateApi generic parameter. To do so, use the #[concordium(state_parameter = "NameOfGenericParameter")] attribute on the type you are deriving StateClone for.

Example

#[derive(Serial, DeserialWithState, StateClone)]
#[concordium(state_parameter = "S")]
struct MyState<S> {
   my_state_map: StateMap<SomeType, SomeOtherType, S>,
}