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§
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(&self, ua: &str) -> Result<(), WebViewError>
fn set_user_agent(&self, ua: &str) -> Result<(), WebViewError>
Set the user agent string for the WebView
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 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.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".