Crate windows_core
Expand description
§windows-core
The windows-core crate provides COM and WinRT types, traits, and macros for the windows-* family of crates.
Start by adding the following to your Cargo.toml file:
[dependencies.windows-core]
version = "0.100"Use the core types as needed:
use windows_core::{h, Result, HRESULT, HSTRING};
// WinRT reference-counted strings.
let name: &HSTRING = h!("Windows.Foundation.Uri");
assert_eq!(name, &HSTRING::from("Windows.Foundation.Uri"));
// HRESULT-based results.
fn check(code: HRESULT) -> Result<()> {
code.ok()
}
assert!(check(HRESULT(0)).is_ok());
assert!(check(HRESULT(-2147467259)).is_err());Macros§
- h
- A literal HSTRING, length-prefixed wide string with a trailing null terminator.
- implement_
decl - Declares a Rust type as the COM implementer of one or more interfaces, without using
the
#[implement]proc-macro. - interface_
decl - Declares a COM interface inheriting from
IUnknown, without using the#[interface]proc-macro. - link
- Defines an external function to import.
- s
- A literal UTF-8 string with a trailing null terminator.
- w
- A literal UTF-16 wide string with a trailing null terminator.
Structs§
- Agile
Reference - A type representing an agile reference to a COM/WinRT object.
- Array
- A WinRT array stores elements contiguously in a heap-allocated buffer.
- BOOL
- A 32-bit Windows Boolean value.
- BSTR
- A length-prefixed wide string.
- ComObject
- A counted pointer to a heap-allocated type that implements COM interfaces.
- Error
- A Windows error code with optional COM error information.
- Event
- A type that you can use to declare and implement an event of a specified delegate type.
- Event
Revoker - A handle that automatically revokes an event registration when dropped.
- GUID
- A globally unique identifier (GUID).
- HRESULT
- An error code value returned by most COM functions.
- HSTRING
- An (HSTRING) is a reference-counted and immutable UTF-16 string type.
- HString
Builder - Builder for preallocating immutable
HSTRINGvalues. - IInspectable
- The base interface for WinRT classes, interfaces, and boxed values.
- IUnknown
- Base interface for all COM interfaces.
- InRef
- A borrowed ABI-compatible input parameter.
- Interface
Ref - A borrowed COM interface pointer with the same representation as
I. - NTSTATUS
- An error or status code value returned by some operating system functions.
- OutRef
- A borrowed ABI-compatible out parameter.
- PCSTR
- A pointer to a constant null-terminated string of 8-bit Windows (ANSI) characters.
- PCWSTR
- A pointer to a constant null-terminated string of 16-bit Unicode characters.
- PSTR
- A pointer to a null-terminated string of 8-bit Windows (ANSI) characters.
- PWSTR
- A pointer to a null-terminated string of 16-bit Unicode characters.
- RPC_
STATUS - An error or status code value returned by some operating system functions.
- Static
ComObject - Stores a COM object in static memory.
- WIN32_
ERROR - An error or status code value returned by some operating system functions.
- Weak
Weakholds a non-owning reference to an object.
Traits§
- AsImpl
- A trait for retrieving the implementation behind a COM or WinRT interface.
- ComObject
Inner - Identifies types that can be placed in
ComObject. - ComObject
Interface - Describes the COM interfaces implemented by a specific COM object.
- Interface
- Provides low-level access to a COM interface vtable.
- OutParam
- Converts values to Windows API output parameters.
- Param
- Converts values to Windows API input parameters.
Functions§
- factory
- Attempts to load the factory object for the given WinRT class. This can be used to access COM interfaces implemented on a Windows Runtime class factory.
- init_
mta - Initializes COM for apartment-agnostic code and keeps the multithreaded apartment alive for the rest of the process.
Type Aliases§
- Ref
- The parameter type for a generic type
Tused in_Impltrait method signatures. - Result
- A specialized
Resulttype that provides Windows error information.