pub unsafe trait FromUnpinned<Source>where
Self: Sized,{
type PinData;
// Required methods
unsafe fn from_unpinned(src: Source) -> (Self, Self::PinData);
unsafe fn on_pin(&mut self, pin_data: Self::PinData);
}Expand description
Trait to build StackPinned values from unpinned types.
Implementers of FromUnpinned<Source> indicate that they can be built from a Source instance,
to the condition that they will be pinned afterwards.
§Safety
This trait both exposes unsafe functions and is unsafe to implement.
- Unsafe functions are exposed because the functions have the preconditions of having to be
called from the
stack_letmacro. - The trait itself is unsafe to implement because implementers must provide implementations of the functions that must uphold invariants that cannot be checked by the compiler. See the documentation of each function for information on the invariants.
Required Associated Types§
Required Methods§
Sourceunsafe fn from_unpinned(src: Source) -> (Self, Self::PinData)
unsafe fn from_unpinned(src: Source) -> (Self, Self::PinData)
Performs a first initialization step, resulting in the creation of the Self instance.
§Safety
- This function is used by the construction macro, it is never safe to call directly.
- Implementers of this function are not allowed to consider that the type won’t ever move yet.
(in particular, the
Selfinstance is returned by this function). The type should be movable at this point.
Sourceunsafe fn on_pin(&mut self, pin_data: Self::PinData)
unsafe fn on_pin(&mut self, pin_data: Self::PinData)
Performs a second initialization step, resulting in the pinning of the Self instance.
§Safety
- This function is used by the construction macro, it is never safe to call directly.
- Implementers of this function are allowed to consider that the type won’t move ever again. You can for instance set autoborrows safely in this function.
- For convenience, a naked mutable borrow is directly given. Implementers of this function are not allowed to move out of this mutable borrow.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.