Trait cglue::trait_group::Opaquable
source · [−]pub unsafe trait Opaquable: Sized {
type OpaqueTarget;
fn into_opaque(self) -> Self::OpaqueTarget { ... }
}
Expand description
Describes an opaquable object.
This trait provides a safe many-traits-to-one conversion. For instance, concrete vtable types
get converted to c_void
types, and so on.
Safety
Implementor of this trait must ensure the same layout of regular and opaque data. Generally, this means using the same structure, but taking type T and converting it to c_void, but it is not limited to that.
In addition, it is key to know that any functions on the type that expect a concrete type
parameter become undefined behaviour. For instance, moving out of a opaque Box
is
undefined behaviour.
Associated Types
type OpaqueTarget
Provided methods
fn into_opaque(self) -> Self::OpaqueTarget
fn into_opaque(self) -> Self::OpaqueTarget
Transform self into an opaque version of the trait object.
The opaque version safely destroys type information, and after this point there is no way back.