Crate wry[][src]

Wry is a Cross-platform WebView rendering library.

There are two main ways to build WebView windows: Application and build by yourself.

Building WebView windows through Application

Application is the recommended way to build the WebView windows. It provides ergonomic and unified APIs across all platforms. To get started, you simply create an Application first:

let application = Application::new()?;

Once you have your application instance, you can create the WebView window by calling Application::add_window with Attributes as the argument to configure the WebView window. If you don’t have any preference, you could just set it with Default::default().

let attributes = Attributes {
    url: Some("https://tauri.studio".to_string()),
    title: String::from("Hello World!"),
    // Initialization scripts can be used to define javascript functions and variables.
    initialization_scripts: vec![
        String::from("breads = NaN"),
        String::from("menacing = 'ゴ'"),
    ],
    ..Default::default()
};

let window = app.add_window(attributes)?;

Run the application with run in the end. This will consume the instance and run the application on current thread.

application.run();

Building WebView windows by yourself

If you want to control whole windows creation and events handling, you can use WebViewBuilder / WebView under webview module to build it all by yourself. You need winit for you to build the window across all platforms except Linux. We still need Gtk’s library to build the WebView, so it’s gtk-rs on Linux.

Feature flags

Wry uses a set of feature flags to toggle several advanced features.

  • file-drop: Enable FileDropHandler to control the behaviour when there are files interacting with the window.
  • protocol: Enable CustomProtocol to define custom URL scheme for handling tasks like loading assets.

Debug build

Debug profile enables tools like inspector for development or debug usage. Note this will call private APIs on macOS.

Re-exports

pub use webview::RpcRequest;
pub use webview::RpcResponse;

Modules

webview

WebView struct and associated types.

Structs

Application

Provides a way to create and manage WebView windows.

ApplicationProxy

A proxy to sent custom messages to Application.

Attributes

Attributes to use when creating a webview window.

CustomProtocol

A protocol to define custom URL scheme for handling tasks like loading assets.

Icon

An icon used for the window title bar, taskbar, etc.

WindowProxy

A proxy to customize its corresponding WebView window.

Enums

Error

Errors returned by wry.

FileDropEvent

An event enumeration sent to FileDropHandler.

Message

Describes a general message.

Value

Represents any valid JSON value.

WindowMessage

Describes a message for a WebView window.

Type Definitions

FileDropHandler

A listener closure to process incoming FileDropEvent of the window.

Result

Convenient type alias of Result type for wry.

WindowId
WindowRpcHandler

The RPC handler to Communicate between the host Rust code and Javascript on webview.