Skip to main content

SMapRuntime

Trait SMapRuntime 

Source
pub trait SMapRuntime<FromRuntime, ToRuntime>: SMove
where 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§

Source

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§

Source§

impl<FromRuntime, ToRuntime> SMapRuntime<FromRuntime, ToRuntime> for StorageStateOwned
where FromRuntime: StateMachineImpl, ToRuntime: StateMachineImpl,

Source§

impl<FromRuntime, ToRuntime> SMapRuntime<FromRuntime, ToRuntime> for StorageStateOwnedBox
where FromRuntime: StateMachineImpl, ToRuntime: StateMachineImpl,

Source§

impl<FromRuntime, ToRuntime> SMapRuntime<FromRuntime, ToRuntime> for StorageStateOwnedPinBox
where FromRuntime: StateMachineImpl + Unpin, ToRuntime: StateMachineImpl,

Available on crate feature alloc only.