blckngm / webview2

Rust bindings for WebView2
MIT License
73 stars 12 forks source link
gui windows

Rust bindings for WebView2:

The Microsoft Edge WebView2 control enables you to embed web technologies (HTML, CSS, and JavaScript) in your native applications. The WebView2 control uses Microsoft Edge (Chromium) as the rendering engine to display the web content in native applications. With WebView2, you may embed web code in different parts of your native application, or build the entire native application within a single WebView. For information on how to start building a WebView2 application, see Get Started.

API

The webview2 crate contains high-level, idiomatic wrappers for the raw COM APIs, which can be found in the webview2-sys crate.

The API mapping should be quite straightforward.

The CreateCoreWebView2EnvironmentWithDetails function does not have a direct equivalent. It is replaced with a nicer EnvironmentBuilder API. The GetAvailableCoreWebView2BrowserVersionString and CompareBrowserVersions functions are also exposed through the builder.

Runtime

The Edge browser from beta, dev or canary channels (>= 86.0.622.0) or the Evergreen WebView2 Runtime need to be installed for this to actually work. Or the build method will return an error.

WebView2Loader

A binary library WebView2Loader from the WebView2 SDK need to be used, either the DLL WebView2Loader.dll or the static library WebView2LoaderStatic.lib. This brings some complexities:

Examples

See the examples directory, especially the heavily commented win32 example.