Crate wry[−][src]
Wry is a Cross-platform WebView rendering library.
To build a Window with WebView embedded, we could use application
module to create
EventLoop
and the window. It’s a module that re-exports APIs from winit. Then
use webview
module to create the WebView
from the Window
. Here’s a minimum example
showing how to create a hello world window and load the url to Tauri website.
fn main() -> wry::Result<()> { use wry::{ application::{ event::{Event, StartCause, WindowEvent}, event_loop::{ControlFlow, EventLoop}, window::WindowBuilder, }, webview::WebViewBuilder, }; let event_loop = EventLoop::new(); let window = WindowBuilder::new() .with_title("Hello World") .build(&event_loop)?; let _webview = WebViewBuilder::new(window)? .with_url("https://tauri.studio")? .build()?; event_loop.run(move |event, _, control_flow| { *control_flow = ControlFlow::Poll; match event { Event::NewEvents(StartCause::Init) => println!("Wry has started!"), Event::WindowEvent { event: WindowEvent::CloseRequested, .. } => *control_flow = ControlFlow::Exit, _ => (), } }); }
Feature flags
Wry uses a set of feature flags to toggle several advanced features.
file-drop
: Enablewith_file_drop_handler
to control the behaviour when there are files interacting with the window.protocol
: Enablewith_custom_protocol
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.
Modules
application | Re-exported winit API with extended features. |
webview |
|
Enums
Error | Errors returned by wry. |
Value | Represents any valid JSON value. |
Type Definitions
Result | Convenient type alias of Result type for wry. |