pub struct ComPtr<T: Interface> { /* private fields */ }Expand description
Owning, non-null COM interface pointer: holds exactly one reference.
Not Send/Sync: the native objects are UI-thread affine.
Implementations§
Source§impl<T: Interface> ComPtr<T>
impl<T: Interface> ComPtr<T>
Sourcepub unsafe fn from_raw(raw: *mut T) -> Option<Self>
pub unsafe fn from_raw(raw: *mut T) -> Option<Self>
Takes ownership of one existing reference (no AddRef). Returns
None for null.
§Safety
raw must be null or a valid pointer to a COM object implementing T
whose reference the caller owns.
Sourcepub unsafe fn from_raw_add_ref(raw: *mut T) -> Option<Self>
pub unsafe fn from_raw_add_ref(raw: *mut T) -> Option<Self>
AddRefs a borrowed pointer and wraps it. Returns None for null.
§Safety
raw must be null or a valid pointer to a COM object implementing T.
Sourcepub fn cast<U: Interface>(&self) -> Result<ComPtr<U>, HResult>
pub fn cast<U: Interface>(&self) -> Result<ComPtr<U>, HResult>
QueryInterface for U.
The native library compares against the IIDs materialized by com.h
(see crate::Guid::as_com_h_materialized), Rust-implemented objects
accept both forms; so the materialized form is tried first and the IDL
form second.
Trait Implementations§
Auto Trait Implementations§
impl<T> !Send for ComPtr<T>
impl<T> !Sync for ComPtr<T>
impl<T> Freeze for ComPtr<T>
impl<T> RefUnwindSafe for ComPtr<T>
impl<T> Unpin for ComPtr<T>
impl<T> UnsafeUnpin for ComPtr<T>
impl<T> UnwindSafe for ComPtr<T>
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
Mutably borrows from an owned value. Read more