[][src]Crate winrt

A crate for providing native and familiar support for the Windows Runtime for Rust developers.

To use, start by importing the types that you need.

use winrt::import;

import!(
    dependencies
        os
    types
        windows::foundation::Uri
);

// Make use of any WinRT APIs as needed.
// For example, here is an example of using the Windows.Foundation.Uri class:
fn main() -> winrt::Result<()> {
    use windows::foundation::Uri;

    let uri = Uri::create_uri("http://kennykerr.ca")?;
    println!("domain: {}", uri.domain()?);
    println!("port: {}", uri.port()?);
    println!("string: {}", uri.to_string()?);

    Ok(())
}

The actual APIs available to you will depend on what WinRT modules you are using. The documentation found here is relevant for core functionality for WinRT, but ultimately the code you will interact with most will be generated by this crate from metadata. For example, documentation on using the window::foundation::Uri type above, can be found here. Of course, when using these APIs from Rust, you will have to remember to translate CamelCase to snake_case as is the convention in Rust.

This program will print the following output:

domain: kennykerr.ca
port: 80
string: http://kennykerr.ca/

Macros

build

A macro for generating WinRT modules to a .rs file at build time.

import

A macro for generating WinRT modules into the current module.

Structs

Array

A WinRT array

Error

A WinRT error object consisting of both an error code as well as detailed error information for debugging.

ErrorCode

An ErrorCode, sometimes called an HRESULT, is the error code associated with a WinRT error.

HString

A WinRT string, sometimes called an HSTRING.

Object

A WinRT object that may be used as a polymorphic stand-in for any WinRT class, interface, or boxed value.

Type Definitions

Result

An alias for std::result::Result<T, winrt::Error>.