Struct windows_core::InterfaceRef
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§
§impl<'a, I: Interface> InterfaceRef<'a, I>
impl<'a, I: Interface> InterfaceRef<'a, I>
pub unsafe fn from_raw(ptr: NonNull<c_void>) -> Self
pub unsafe fn from_raw(ptr: NonNull<c_void>) -> Self
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.
pub fn from_interface(interface: &I) -> Self
pub fn from_interface(interface: &I) -> Self
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.
pub fn to_owned(self) -> I
pub fn to_owned(self) -> I
Calls AddRef on the underlying COM interface and returns an “owned” (counted) reference.