pub trait WebViewController: Send + Sync {
Show 21 methods
// Required methods
fn load_url(&self, url: &str) -> Result<(), WebViewError>;
fn load_data(
&self,
request: LoadDataRequest<'_>,
) -> Result<(), WebViewError>;
fn exec_js(&self, js: &str) -> Result<(), WebViewError>;
fn eval_js<'life0, 'life1, 'async_trait>(
&'life0 self,
js: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Value, WebViewScriptError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn post_message(&self, message: &str) -> Result<(), WebViewError>;
fn clear_browsing_data(&self) -> Result<(), WebViewError>;
fn set_user_agent_override(
&self,
user_agent: UserAgentOverride,
) -> Result<(), WebViewError>;
// Provided methods
fn current_url<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, WebViewError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn reload(&self) -> Result<(), WebViewError> { ... }
fn go_back(&self) -> Result<(), WebViewError> { ... }
fn go_forward(&self) -> Result<(), WebViewError> { ... }
fn list_cookies<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<WebViewCookie>, WebViewError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn set_cookie<'life0, 'async_trait>(
&'life0 self,
_request: WebViewCookieSetRequest,
) -> Pin<Box<dyn Future<Output = Result<(), WebViewError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn delete_cookie<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_name: &'life1 str,
_domain: &'life2 str,
_path: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<(), WebViewError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait { ... }
fn clear_cookies<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), WebViewError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn clear_site_data<'life0, 'life1, 'async_trait>(
&'life0 self,
_url: &'life1 str,
_options: ClearSiteDataOptions,
) -> Pin<Box<dyn Future<Output = Result<ClearSiteDataResult, WebViewError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn take_screenshot<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, WebViewError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn start_network_capture<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), WebViewError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn stop_network_capture<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), WebViewError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn network_entries<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<NetworkCaptureSnapshot, WebViewError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn clear_network_capture<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), WebViewError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Interface for controlling WebView (100% copy from lxapp)
Required Methods§
Sourcefn load_data(&self, request: LoadDataRequest<'_>) -> Result<(), WebViewError>
fn load_data(&self, request: LoadDataRequest<'_>) -> Result<(), WebViewError>
Load HTML data into the WebView.
Sourcefn exec_js(&self, js: &str) -> Result<(), WebViewError>
fn exec_js(&self, js: &str) -> Result<(), WebViewError>
Execute JavaScript in the WebView without observing its return value.
Sourcefn eval_js<'life0, 'life1, 'async_trait>(
&'life0 self,
js: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Value, WebViewScriptError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn eval_js<'life0, 'life1, 'async_trait>(
&'life0 self,
js: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Value, WebViewScriptError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Evaluate JavaScript in the WebView and return the decoded JSON value.
Implementations are required to be both CSP-safe (no (0,eval) /
new Function — pages whose CSP omits 'unsafe-eval' must still
work) and await-aware (top-level await in the user expression
resolves before the future returns). Platforms achieve this by
dispatching through the native await-capable API
(callAsyncJavaScript: on Apple, LingXiaProxy.resolveEval JS
bridge on Android/Harmony).
Sourcefn post_message(&self, message: &str) -> Result<(), WebViewError>
fn post_message(&self, message: &str) -> Result<(), WebViewError>
Post a message to the WebView
Sourcefn clear_browsing_data(&self) -> Result<(), WebViewError>
fn clear_browsing_data(&self) -> Result<(), WebViewError>
Clear browsing data from the WebView
Sourcefn set_user_agent_override(
&self,
user_agent: UserAgentOverride,
) -> Result<(), WebViewError>
fn set_user_agent_override( &self, user_agent: UserAgentOverride, ) -> Result<(), WebViewError>
Override or restore the WebView user agent.
Provided Methods§
Sourcefn current_url<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, WebViewError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn current_url<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, WebViewError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Return the platform WebView’s current URL.
Sourcefn reload(&self) -> Result<(), WebViewError>
fn reload(&self) -> Result<(), WebViewError>
Reload the current WebView document.
Sourcefn go_back(&self) -> Result<(), WebViewError>
fn go_back(&self) -> Result<(), WebViewError>
Navigate back in WebView history.
Sourcefn go_forward(&self) -> Result<(), WebViewError>
fn go_forward(&self) -> Result<(), WebViewError>
Navigate forward in WebView history.
List HTTP cookies from the platform WebView cookie store.
Set an HTTP cookie through the platform WebView cookie store.
Delete an HTTP cookie from the platform WebView cookie store.
Clear all HTTP cookies from the platform WebView cookie store.
Sourcefn clear_site_data<'life0, 'life1, 'async_trait>(
&'life0 self,
_url: &'life1 str,
_options: ClearSiteDataOptions,
) -> Pin<Box<dyn Future<Output = Result<ClearSiteDataResult, WebViewError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn clear_site_data<'life0, 'life1, 'async_trait>(
&'life0 self,
_url: &'life1 str,
_options: ClearSiteDataOptions,
) -> Pin<Box<dyn Future<Output = Result<ClearSiteDataResult, WebViewError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Clear data owned by the current website without clearing the shared browser profile. Platforms report whether their network cache supports site-scoped removal.
Sourcefn take_screenshot<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, WebViewError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn take_screenshot<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, WebViewError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Capture a PNG screenshot of the WebView’s visible content. Returns raw PNG-encoded bytes ready to be base64’d over the wire.
Sourcefn start_network_capture<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), WebViewError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn start_network_capture<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), WebViewError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Begin recording network requests/responses into a bounded per-webview
buffer, retrievable via Self::network_entries. Dev-tooling only;
implemented on platforms whose WebView exposes an inspection protocol
(currently Windows/WebView2 via the Chrome DevTools Protocol).
Sourcefn stop_network_capture<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), WebViewError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stop_network_capture<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), WebViewError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Stop recording network traffic. Captured entries are kept until
Self::clear_network_capture or the webview is torn down.
Sourcefn network_entries<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<NetworkCaptureSnapshot, WebViewError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn network_entries<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<NetworkCaptureSnapshot, WebViewError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Snapshot the captured network entries (oldest first). dropped counts
entries evicted from the ring buffer since the last clear.
Sourcefn clear_network_capture<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), WebViewError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn clear_network_capture<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), WebViewError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Drop all captured entries (leaves capture enabled if it was on).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".