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.
Trait Implementations§
§impl<'a, I> Clone for InterfaceRef<'a, I>
impl<'a, I> Clone for InterfaceRef<'a, I>
§impl<'a, I: Debug + Interface> Debug for InterfaceRef<'a, I>
impl<'a, I: Debug + Interface> Debug for InterfaceRef<'a, I>
§impl<'a, I: Interface> Deref for InterfaceRef<'a, I>
impl<'a, I: Interface> Deref for InterfaceRef<'a, I>
§impl<'a, 'i: 'a, I: Interface> From<&'i I> for InterfaceRef<'a, I>
impl<'a, 'i: 'a, I: Interface> From<&'i I> for InterfaceRef<'a, I>
§fn from(interface: &'a I) -> InterfaceRef<'a, I>
fn from(interface: &'a I) -> InterfaceRef<'a, I>
impl<'a, I> Copy for InterfaceRef<'a, I>
Auto Trait Implementations§
impl<'a, I> Freeze for InterfaceRef<'a, I>
impl<'a, I> RefUnwindSafe for InterfaceRef<'a, I>where
I: RefUnwindSafe,
impl<'a, I> !Send for InterfaceRef<'a, I>
impl<'a, I> !Sync for InterfaceRef<'a, I>
impl<'a, I> Unpin for InterfaceRef<'a, I>
impl<'a, I> UnwindSafe for InterfaceRef<'a, I>where
I: RefUnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)