[][src]Struct better_web_view::WebViewBuilder

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

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(())
        .router(Router::default())
        .build()
        .unwrap()
        .run()
        .unwrap();
}

Fields

title: &'a strcontent: Option<Content<C>>width: i32height: i32resizable: booldebug: boolrouter: Option<Router<'a, T>>user_data: Option<T>

Methods

impl<'a, T: 'a, C> WebViewBuilder<'a, T, C> where
    C: AsRef<str>, 
[src]

pub fn new() -> Self[src]

pub fn title(self, title: &'a str) -> Self[src]

Sets the title of the WebView window.

Defaults to "Application".

pub fn content(self, content: Content<C>) -> Self[src]

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

pub fn size(self, width: i32, height: i32) -> Self[src]

Sets the size of the WebView window.

Defaults to 800 x 600.

pub fn resizable(self, resizable: bool) -> Self[src]

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

Defaults to true.

pub fn debug(self, debug: bool) -> Self[src]

Enables or disables debug mode.

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

pub fn router(self, router: Router<'a, T>) -> Self[src]

Sets the route. Sets a router. The router determine which callback is executed when receives a javascript request

pub fn user_data(self, user_data: T) -> Self[src]

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.

pub fn build(self) -> WVResult<WebView<'a, T>>[src]

Validates provided arguments and returns a new WebView if successful.

pub fn run(self) -> WVResult<T>[src]

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

Equivalent to build()?.run().

Trait Implementations

impl<'a, T: 'a, C> Default for WebViewBuilder<'a, T, C> where
    C: AsRef<str>, 
[src]

Auto Trait Implementations

impl<'a, T, C> Send for WebViewBuilder<'a, T, C> where
    C: Send,
    T: Send

impl<'a, T, C> Sync for WebViewBuilder<'a, T, C> where
    C: Sync,
    T: Sync

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]