pub struct InterfaceRef<'a, I>(/* private fields */);
Expand description
This has the same memory representation as IFoo
, but represents a borrowed interface pointer.
This type has no Drop
impl; it does not AddRef/Release the given interface. However, because
it has a lifetime parameter, it always represents a non-null pointer to an interface.
Implementations§
Source§impl<I> InterfaceRef<'_, I>where
I: Interface,
impl<I> InterfaceRef<'_, I>where
I: Interface,
Sourcepub unsafe fn from_raw(ptr: NonNull<c_void>) -> InterfaceRef<'_, I>
pub unsafe fn from_raw(ptr: NonNull<c_void>) -> InterfaceRef<'_, I>
Creates an InterfaceRef
from a raw pointer. This is extremely dangerous, since there
is no lifetime tracking at all!
§Safety
The caller must guarantee that the 'a
lifetime parameter is bound by context to a correct
lifetime.
Sourcepub fn from_interface(interface: &I) -> InterfaceRef<'_, I>
pub fn from_interface(interface: &I) -> InterfaceRef<'_, I>
Creates an InterfaceRef
from an interface reference. This safely associates the lifetime
of the interface reference with the 'a
parameter of InterfaceRef
. This allows for
lifetime checking without calling AddRef/Release on the underlying lifetime, which can
improve efficiency.
Trait Implementations§
Source§impl<I> Clone for InterfaceRef<'_, I>
impl<I> Clone for InterfaceRef<'_, I>
Source§fn clone(&self) -> InterfaceRef<'_, I>
fn clone(&self) -> InterfaceRef<'_, I>
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read more