29 releases (breaking)
|0.23.0||Feb 17, 2023|
|0.21.0||Oct 25, 2022|
|0.18.0||Jun 28, 2022|
|0.14.0||Mar 22, 2022|
|0.7.0||Nov 9, 2021|
#36 in Windows APIs
29,124 downloads per month
Used in 72 crates (10 directly)
This crate implements Rust bindings for the WebView2 COM APIs, as well as several important Win32 APIs necessary to build a standalone GUI application hosting WebView2. The bindings are generated by the Windows crate in webview2-com-sys.
Include a reference to
webview2-com in your
[dependencies] webview2-com = "0.23.0"
See the docs or take a look at the sample.rs example (adapted from microsoft/windows-samples-rs) for more details.
Most of the bindings are re-exported transparently from
webview2-com-sys, and they are still marked
unsafe. Unlike typical idiomatic Rust crates wrapped around a
-sys crate, the emphasis of this crate is on writing as little manual wrapper code as possible. This way,
webview2-com can project 100% of the WebView2 COM API, but the downside is you will need to wrap most uses in an
unsafe block or function.
Most of the code added by this crate consists of convenience types to implement COM interfaces that are required for callbacks and setting options:
- callback.rs: Implements all of the event sink handler interfaces used by WebView2.
- options.rs: Implements the
ICoreWebView2EnvironmentOptionsinterface which is passed to
CreateCoreWebView2EnvironmentWithOptionsif you want to customize the environment.
There are also some utilities for dealing with
PWSTR in/out-params that may be useful:
The Windows crate requires a Windows Metadata (
winmd) file describing the API. The one used in this crate was generated with the webview2-win32md project. This crate needs it to use the
#[implement] macro from the Windows crate.