Struct winrt::ComPtr

source ·
#[repr(C)]
pub struct ComPtr<T>(_);
Expand description

Smart pointer for Windows Runtime objects. This pointer automatically maintains the reference count of the underlying COM object.

Implementations§

Creates a ComPtr to wrap a raw pointer. It takes ownership over the pointer which means it does not call AddRef. T must be a COM interface that inherits from IUnknown. The wrapped pointer must not be null.

Creates an optional ComPtr to wrap a raw pointer that may be null. It takes ownership over the pointer which means it does not call AddRef. T must be a COM interface that inherits from IUnknown.

Changes the type of the underlying COM object to a different interface without doing QueryInterface. This is a runtime no-op, but you need to be sure that the interface is compatible.

Gets the fully qualified name of the current Windows Runtime object. This is only available for interfaces that inherit from IInspectable and are not factory or statics interfaces.

Examples

Basic usage:

use winrt::*;
use winrt::windows::foundation::Uri;

let uri = FastHString::new("https://www.rust-lang.org");
let uri = Uri::create_uri(&uri).unwrap();
assert_eq!("Windows.Foundation.Uri", uri.get_runtime_class_name().to_string());

Retrieves a ComPtr to the specified interface, if it is supported by the underlying object. If the requested interface is not supported, None is returned.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
The resulting type after dereferencing.
Dereferences the value.
Mutably dereferences the value.
Executes the destructor for this type. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
Formats the value using the given formatter.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.