pub trait SMapRuntime<FromRuntime, ToRuntime>: SMovewhere
FromRuntime: StateMachineImpl,
ToRuntime: StateMachineImpl,{
// Required method
fn map_runtime<StateMarkerType, F>(
state: State<Self, FromRuntime, StateMarkerType>,
f: F,
) -> State<Self, ToRuntime, StateMarkerType>
where F: FnOnce(FromRuntime) -> ToRuntime;
}Expand description
Storage backend that can transform the runtime value while preserving state.
This is an internal storage hook used by wrappers that carry extra state
metadata while retagging or discriminating values. It is separate from
SMove because consuming a state token by value does
not always mean the runtime value itself can be safely moved out. For
example, pinned storage can only implement this for source runtimes that are
safe to move out of the pin.
Required Methods§
Sourcefn map_runtime<StateMarkerType, F>(
state: State<Self, FromRuntime, StateMarkerType>,
f: F,
) -> State<Self, ToRuntime, StateMarkerType>where
F: FnOnce(FromRuntime) -> ToRuntime,
fn map_runtime<StateMarkerType, F>(
state: State<Self, FromRuntime, StateMarkerType>,
f: F,
) -> State<Self, ToRuntime, StateMarkerType>where
F: FnOnce(FromRuntime) -> ToRuntime,
Applies f to the runtime value inside state and returns the same
storage and state marker with the new runtime type.
This operation must preserve all state metadata owned by the storage, such as transition traces or union discriminators. It may only be implemented when the backend can safely move the source runtime value out of its representation.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl<FromRuntime, ToRuntime> SMapRuntime<FromRuntime, ToRuntime> for StorageStateOwnedwhere
FromRuntime: StateMachineImpl,
ToRuntime: StateMachineImpl,
impl<FromRuntime, ToRuntime> SMapRuntime<FromRuntime, ToRuntime> for StorageStateOwnedBoxwhere
FromRuntime: StateMachineImpl,
ToRuntime: StateMachineImpl,
impl<FromRuntime, ToRuntime> SMapRuntime<FromRuntime, ToRuntime> for StorageStateOwnedPinBox
alloc only.