Struct web_view::WebViewBuilder
source · 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 str
content: Option<Content<C>>
width: i32
height: i32
resizable: bool
debug: bool
invoke_handler: Option<I>
user_data: Option<T>
Implementations
sourceimpl<'a, T: 'a, I, C> WebViewBuilder<'a, T, I, C>where
I: FnMut(&mut WebView<'_, T>, &str) -> WVResult + 'a,
C: AsRef<str>,
impl<'a, T: 'a, I, C> WebViewBuilder<'a, T, I, C>where
I: FnMut(&mut WebView<'_, T>, &str) -> WVResult + 'a,
C: AsRef<str>,
sourcepub fn new() -> Self
pub fn new() -> Self
Alias for WebViewBuilder::default()
.
sourcepub fn title(self, title: &'a str) -> Self
pub fn title(self, title: &'a str) -> Self
Sets the title of the WebView window.
Defaults to "Application"
.
sourcepub fn content(self, content: Content<C>) -> Self
pub fn content(self, content: Content<C>) -> Self
Sets the content of the WebView. Either a URL or a HTML string.
sourcepub fn size(self, width: i32, height: i32) -> Self
pub fn size(self, width: i32, height: i32) -> Self
Sets the size of the WebView window.
Defaults to 800 x 600.
sourcepub fn resizable(self, resizable: bool) -> Self
pub fn resizable(self, resizable: bool) -> Self
Sets the resizability of the WebView window. If set to false, the window cannot be resized.
Defaults to true
.
sourcepub fn debug(self, debug: bool) -> Self
pub fn debug(self, debug: bool) -> Self
Enables or disables debug mode.
Defaults to true
for debug builds, false
for release builds.
sourcepub fn invoke_handler(self, invoke_handler: I) -> Self
pub fn invoke_handler(self, invoke_handler: I) -> Self
sourcepub fn user_data(self, user_data: T) -> Self
pub fn user_data(self, user_data: T) -> Self
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.
Trait Implementations
Auto Trait Implementations
impl<'a, T, I, C> RefUnwindSafe for WebViewBuilder<'a, T, I, C>where
C: RefUnwindSafe,
I: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, T, I, C> Send for WebViewBuilder<'a, T, I, C>where
C: Send,
I: Send,
T: Send,
impl<'a, T, I, C> Sync for WebViewBuilder<'a, T, I, C>where
C: Sync,
I: Sync,
T: Sync,
impl<'a, T, I, C> Unpin for WebViewBuilder<'a, T, I, C>where
C: Unpin,
I: Unpin,
T: Unpin,
impl<'a, T, I, C> UnwindSafe for WebViewBuilder<'a, T, I, C>where
C: UnwindSafe,
I: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more