Skip to main content

WebViewController

Trait WebViewController 

Source
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§

Source

fn load_url(&self, url: &str) -> Result<(), WebViewError>

Load a URL in the WebView

Source

fn load_data(&self, request: LoadDataRequest<'_>) -> Result<(), WebViewError>

Load HTML data into the WebView.

Source

fn exec_js(&self, js: &str) -> Result<(), WebViewError>

Execute JavaScript in the WebView without observing its return value.

Source

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).

Source

fn post_message(&self, message: &str) -> Result<(), WebViewError>

Post a message to the WebView

Source

fn clear_browsing_data(&self) -> Result<(), WebViewError>

Clear browsing data from the WebView

Source

fn set_user_agent_override( &self, user_agent: UserAgentOverride, ) -> Result<(), WebViewError>

Override or restore the WebView user agent.

Provided Methods§

Source

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.

Source

fn reload(&self) -> Result<(), WebViewError>

Reload the current WebView document.

Source

fn go_back(&self) -> Result<(), WebViewError>

Navigate back in WebView history.

Source

fn go_forward(&self) -> Result<(), WebViewError>

Navigate forward in WebView history.

Source

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,

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.

Source

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,

Clear all HTTP cookies from the platform WebView cookie store.

Source

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.

Source

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.

Source

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).

Source

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.

Source

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.

Source

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".

Implementors§