tauri_runtime_wry

Struct WebviewWrapper

source
pub struct WebviewWrapper { /* private fields */ }

Methods from Deref<Target = WebView>§

source

pub fn id(&self) -> &str

Returns the id of this webview.

source

pub fn url(&self) -> Result<String, Error>

Get the current url of the webview

source

pub fn evaluate_script(&self, js: &str) -> Result<(), Error>

Evaluate and run javascript code.

source

pub fn evaluate_script_with_callback( &self, js: &str, callback: impl Fn(String) + Send + 'static, ) -> Result<(), Error>

Evaluate and run javascript code with callback function. The evaluation result will be serialized into a JSON string and passed to the callback function.

Exception is ignored because of the limitation on windows. You can catch it yourself and return as string as a workaround.

  • ** Android:** Not implemented yet.
source

pub fn print(&self) -> Result<(), Error>

Launch print modal for the webview content.

source

pub fn open_devtools(&self)

Open the web inspector which is usually called dev tool.

§Platform-specific
  • Android / iOS: Not supported.
source

pub fn close_devtools(&self)

Close the web inspector which is usually called dev tool.

§Platform-specific
  • Windows / Android / iOS: Not supported.
source

pub fn is_devtools_open(&self) -> bool

Gets the devtool window’s current visibility state.

§Platform-specific
  • Windows / Android / iOS: Not supported.
source

pub fn zoom(&self, scale_factor: f64) -> Result<(), Error>

Set the webview zoom level

§Platform-specific:
  • Android: Not supported.
  • macOS: available on macOS 11+ only.
  • iOS: available on iOS 14+ only.
source

pub fn set_background_color( &self, background_color: (u8, u8, u8, u8), ) -> Result<(), Error>

Specify the webview background color.

The color uses the RGBA format.

§Platfrom-specific:
  • macOS / iOS: Not implemented.
  • Windows:
    • On Windows 7, transparency is not supported and the alpha value will be ignored.
    • On Windows higher than 7: translucent colors are not supported so any alpha value other than 0 will be replaced by 255
source

pub fn load_url(&self, url: &str) -> Result<(), Error>

Navigate to the specified url

source

pub fn load_url_with_headers( &self, url: &str, headers: HeaderMap, ) -> Result<(), Error>

Navigate to the specified url using the specified headers

source

pub fn load_html(&self, html: &str) -> Result<(), Error>

Load html content into the webview

source

pub fn clear_all_browsing_data(&self) -> Result<(), Error>

Clear all browsing data

source

pub fn bounds(&self) -> Result<Rect, Error>

source

pub fn set_bounds(&self, bounds: Rect) -> Result<(), Error>

Set the webview bounds.

This is only effective if the webview was created as a child or created using [WebViewBuilderExtUnix::new_gtk] with gtk::Fixed.

source

pub fn set_visible(&self, visible: bool) -> Result<(), Error>

Shows or hides the webview.

source

pub fn focus(&self) -> Result<(), Error>

Try moving focus to the webview.

source

pub fn focus_parent(&self) -> Result<(), Error>

Try moving focus away from the webview back to the parent window.

§Platform-specific:
  • Android: Not implemented.

Trait Implementations§

source§

impl Clone for WebviewWrapper

source§

fn clone(&self) -> WebviewWrapper

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
source§

impl Deref for WebviewWrapper

source§

type Target = WebView

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl Drop for WebviewWrapper

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

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§

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,

source§

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>,

source§

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>,

source§

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.