Skip to main content

SPinRef

Trait SPinRef 

Source
pub trait SPinRef: SRef {
    // Required method
    fn s_pin_ref<T, State>(inner: &Self::Inner<T, State>) -> Pin<&T>
       where T: StateMachineImpl;
}
Expand description

Storage backend that can expose a pinned runtime reference.

This capability is separate from SRef and SMut because pinning is stronger than ordinary borrowing. A backend should implement this only when it can prove the runtime value will not be moved for the lifetime of the storage object. SPinBox does; ordinary owned storage intentionally does not.

Use this bound for read-only methods that must call APIs taking Pin<&Self>:

fn stable_address<S>(self: &State<S, Self, Ready>) -> usize
where
    S: magicstatemachines::SPinRef,
{
    magicstatemachines::pin_ref(self).stable_address()
}

Required Methods§

Source

fn s_pin_ref<T, State>(inner: &Self::Inner<T, State>) -> Pin<&T>

Borrows the runtime implementation as a pinned shared reference.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl SPinRef for StorageStateOwnedPinBox

Available on crate feature alloc only.