pub struct WebViewBuilder<'a, T: 'a, I, C> {
    pub title: &'a str,
    pub content: Option<Content<C>>,
    pub width: i32,
    pub height: i32,
    pub resizable: bool,
    pub debug: bool,
    pub invoke_handler: Option<I>,
    pub user_data: Option<T>,
}
Expand description

Builder for constructing a WebView instance.

Example

extern crate web_view;

use web_view::*;

fn main() {
    WebViewBuilder::new()
        .title("Minimal webview example")
        .content(Content::Url("https://en.m.wikipedia.org/wiki/Main_Page"))
        .size(800, 600)
        .resizable(true)
        .debug(true)
        .user_data(())
        .invoke_handler(|_webview, _arg| Ok(()))
        .build()
        .unwrap()
        .run()
        .unwrap();
}

Fields

title: &'a strcontent: Option<Content<C>>width: i32height: i32resizable: booldebug: boolinvoke_handler: Option<I>user_data: Option<T>

Implementations

Sets the title of the WebView window.

Defaults to "Application".

Sets the content of the WebView. Either a URL or a HTML string.

Sets the size of the WebView window.

Defaults to 800 x 600.

Sets the resizability of the WebView window. If set to false, the window cannot be resized.

Defaults to true.

Enables or disables debug mode.

Defaults to true for debug builds, false for release builds.

Sets the invoke handler callback. This will be called when a message is received from JavaScript.

Errors

If the closure returns an Err, it will be returned on the next call to step().

Sets the initial state of the user data. This is an arbitrary value stored on the WebView thread, accessible from dispatched closures without synchronization overhead.

Validates provided arguments and returns a new WebView if successful.

Validates provided arguments and runs a new WebView to completion, returning the user data.

Equivalent to build()?.run().

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.