Trait DynamicSend
pub unsafe trait DynamicSend: Send + Sealed {
type Inner;
// Required method
fn extract_if_safe(self) -> Option<Self::Inner>;
}
Expand description
Runtime-checked Send
capability.
Implemented for types that need a static Send
bound, but where it is determined at runtime whether sending a value was
actually safe. Only allows to extract the value if sending across threads is safe, thus fulfilling the Send
supertrait.
§Safety
The implementor has to guarantee that extract_if_safe
returns None
, if the value has been sent between threads while being !Send
.
To uphold the Send
supertrait guarantees, no public API apart from extract_if_safe
must exist that would give access to the inner value from another thread.