pub trait WebViewDelegate: Send + Sync {
// Required methods
fn on_page_started(&self);
fn on_page_finished(&self);
fn handle_post_message(&self, msg: String);
fn log(&self, level: LogLevel, message: &str);
// Provided methods
fn on_load_error(&self, _error: &LoadError) { ... }
fn on_title_changed(&self, _title: &str) { ... }
fn on_favicon_changed(&self, _png_bytes: Vec<u8>) { ... }
fn handle_native_component_message(&self, message_json: &str) { ... }
}Expand description
WebView delegate trait - focused on WebView events only
Required Methods§
Sourcefn on_page_started(&self)
fn on_page_started(&self)
Called when the page starts loading
Sourcefn on_page_finished(&self)
fn on_page_finished(&self)
Called when the page finishes loading
Sourcefn handle_post_message(&self, msg: String)
fn handle_post_message(&self, msg: String)
Handles a postMessage from the page View(WebView)
Provided Methods§
Sourcefn on_load_error(&self, _error: &LoadError)
fn on_load_error(&self, _error: &LoadError)
Called when a main-frame page load fails (e.g. DNS failure, network unreachable, TLS error).
Only fires for the main document; sub-resource errors are ignored. Default is a no-op so existing implementations do not need to change.
Sourcefn on_title_changed(&self, _title: &str)
fn on_title_changed(&self, _title: &str)
Called when the document title changes (where the platform reports it; currently Windows/WebView2). Default is a no-op so existing implementations do not need to change.
Sourcefn on_favicon_changed(&self, _png_bytes: Vec<u8>)
fn on_favicon_changed(&self, _png_bytes: Vec<u8>)
Called when the page favicon changes (where the platform reports it;
currently Windows/WebView2). png_bytes holds the favicon encoded
as PNG; an empty vector means the page has no favicon. Default is a
no-op so existing implementations do not need to change.
Sourcefn handle_native_component_message(&self, message_json: &str)
fn handle_native_component_message(&self, message_json: &str)
Handles a native-component message posted by the page through the
embedded-component channel (window.NativeComponentBridge), where
the platform routes it in-process (currently Windows/WebView2).
message_json is the raw component message (component.mount,
component.update, …). Default is a no-op so existing
implementations do not need to change.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".