Struct webview_app::webview::WebView

source ·
pub struct WebView { /* private fields */ }
Expand description

WebView is a Window running as program including a web view

WebView has to be built with the help of the WebView::builder function

Implementations§

source§

impl WebView

source

pub fn builder(app: &Application) -> WebViewBuilder<'_>

Creates a WebViewBuilder to construct a WebView.

Call several WebViewBuilder functions and create the WebView with build()

§Example
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
Allows console to show up in debug build but not release build.

use webview_app::webview::WebView;
 
fn on_activate(app: &Application)->WebView {
    let webview = 
        WebView::builder()
            .appid("de.uriegel.hello")
            .title("Rust Web View 🦞")
            .url("https://crates.io/crates/webview_app")
            .build();
    webview
}
source

pub fn can_close(&self, val: impl Fn() -> bool + 'static)

Sets a callback which is invoked on closing the app

You can prevent closing the app when returning false

§Example
let can_close = true;
...
webview.can_close(move ||can_close);
source

pub fn connect_request<F: Fn(&Request, String, String, String) -> bool + 'static>( &self, on_request: F, )

When the webview is created, this callback is being called. You can then install WebView requests.

The Callback function has the following parameters: a request object, the request id, the command id (the Webview method) and the JSON payload.

A true return value signals that the request is being processed by this callback.

source

pub fn get_handle(&self) -> WebViewHandle

Retrieving a WebViewHandle to evaluate script in the WebView

source

pub fn eval(handle: WebViewHandle, script: &str)

Evaluates script in the WebView

You need a WebViewHandle which you can retrieve via WebView::get_handle

You do not need a reference to the WebView handle!

source

pub fn execute_javascript(script: &str)

Execute script in webview

Trait Implementations§

source§

impl Clone for WebView

source§

fn clone(&self) -> WebView

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl Freeze for WebView

§

impl !RefUnwindSafe for WebView

§

impl !Send for WebView

§

impl !Sync for WebView

§

impl Unpin for WebView

§

impl !UnwindSafe for WebView

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.