Skip to main content

WebViewController

Trait WebViewController 

Source
pub trait WebViewController: Send + Sync {
Show 16 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(&self, ua: &str) -> 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 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 { ... }
}
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(&self, ua: &str) -> Result<(), WebViewError>

Set the user agent string for the WebView

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

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§