[−][src]Struct com::ComPtr
A transparent ptr to a COM interface.
This is normally not the correct way to interact with an interface. Normally
you'll want to to interact with an interface through a ComRc
which
automatically calls AddRef
and Release
at the right time .
Methods
impl<T: ComInterface + ?Sized> ComPtr<T>
[src]
pub unsafe fn new(ptr: *mut *mut <T as ComInterface>::VTable) -> ComPtr<T>
[src]
Creates a new ComPtr
that comforms to the interface T
Safety
ptr
must be a valid interface pointer for interface T
. An interface
pointer as the name suggests points to an interface struct. A valid
interface is itself trivial castable to a *mut T::VTable
. In other words,
ptr
should also be equal to *mut *mut T::VTable
ptr
must live for at least as long as the ComPtr
. The underlying
COM interface is assumed to correctly implement AddRef and Release such that
the interface will be valid as long as AddRef has been called more times than
Release.
AddRef must have been called on the underlying COM interface that ptr
is pointing
to such that the reference count must be at least 1. It is expected that Release
will eventually be called on this pointer either manually or by passing it into
ComRc::new
which will cause Release to be called on drop of the rc.
When this struct is dropped, release
will be called on the underlying interface.
Panics
Panics if ptr
is null
pub fn upgrade(self) -> ComRc<T>
[src]
Upgrade the ComPtr
to an ComRc
pub fn as_raw(&self) -> *mut *mut <T as ComInterface>::VTable
[src]
Gets the underlying interface ptr. This ptr is only guarnteed to live for
as long as the current ComPtr
is alive.
pub fn get_interface<I: ComInterface + ?Sized>(&self) -> Option<ComPtr<I>>
[src]
A safe version of QueryInterface
. If the backing CoClass implements the
interface I
then a Some
containing an ComRc
pointing to that
interface will be returned otherwise None
will be returned.
Trait Implementations
impl<T: ComInterface + ?Sized> Clone for ComPtr<T>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: ComInterface + ?Sized> From<ComRc<T>> for ComPtr<T>
[src]
fn from(rc: ComRc<T>) -> Self
[src]
Convert from an ComRc
to an ComPtr
Note that this does not call the release on the underlying interface which gurantees that the ComPtr will still point to a valid interface. If Release is never called on this pointer, than memory may be leaked.
impl<T: IClassFactory + ComInterface + ?Sized> IClassFactory for ComPtr<T>
[src]
unsafe fn create_instance(
&self,
aggr: *mut IUnknownVPtr,
riid: *const GUID,
ppv: *mut *mut c_void
) -> HRESULT
[src]
&self,
aggr: *mut IUnknownVPtr,
riid: *const GUID,
ppv: *mut *mut c_void
) -> HRESULT
unsafe fn lock_server(&self, increment: BOOL) -> HRESULT
[src]
impl<T: IUnknown + ComInterface + ?Sized> IUnknown for ComPtr<T>
[src]
Auto Trait Implementations
impl<T: ?Sized> RefUnwindSafe for ComPtr<T> where
T: RefUnwindSafe,
<T as ComInterface>::VTable: RefUnwindSafe,
T: RefUnwindSafe,
<T as ComInterface>::VTable: RefUnwindSafe,
impl<T> !Send for ComPtr<T>
impl<T> !Sync for ComPtr<T>
impl<T: ?Sized> Unpin for ComPtr<T> where
T: Unpin,
T: Unpin,
impl<T: ?Sized> UnwindSafe for ComPtr<T> where
T: UnwindSafe,
<T as ComInterface>::VTable: RefUnwindSafe,
T: UnwindSafe,
<T as ComInterface>::VTable: RefUnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,