pub unsafe trait Interface: Sized {
type Impl;
type Vtable;
const IID: &'static str;
// Provided methods
unsafe fn from_raw(raw: *mut Self::Impl) -> Self { ... }
fn into_raw(self) -> *mut Self::Impl { ... }
fn as_raw(&self) -> *mut Self::Impl { ... }
fn cast<I: Interface>(&self) -> Result<I> { ... }
}Expand description
§Safety
All unsafe implementers of this trait should guarantee ffi::IADLXInterface is the base
type.
The struct must have the same layout as *mut IADLXInterface, preferably
in terms of InterfaceImpl for automatic refcount management.
Required Associated Constants§
Required Associated Types§
Provided Methods§
Sourceunsafe fn from_raw(raw: *mut Self::Impl) -> Self
unsafe fn from_raw(raw: *mut Self::Impl) -> Self
Creates an Interface by taking ownership of the raw COM/ADLX interface pointer.
§Safety
The raw pointer must be owned by the caller and represent a valid ADLX interface pointer.
In other words, it must point to a vtable beginning with the ffi::IADLXInterfaceVtbl
function pointers and match the vtable of Self::Vtable.
Sourcefn into_raw(self) -> *mut Self::Impl
fn into_raw(self) -> *mut Self::Impl
Returns the raw COM/ADLX interface pointer and abandons ownership. It is the caller’s responsibility to release the COM/ADLX interface pointer.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".