pub struct DarwinWKApp { /* private fields */ }
Expand description

Wraps an NSApplication instance with a main window that contains WebView.

See DarwinWKWebView as well.

Example

use darwin_webkit::helpers::dwk_app::DarwinWKApp;
use std::rc::Rc;

unsafe {
    let app = DarwinWKApp::new("Host an app");
    let webview = Rc::new(app.create_webview());

    // add handlers, load HTML, etc...

    app.set_webview(&webview);
    app.run();
}

Implementations§

source§

impl DarwinWKApp

source

pub unsafe fn new(windowTitle: &str) -> DarwinWKApp

Create an app with the given window title

Safety

All the FFI functions are unsafe.

source

pub fn get_app_native_handle(&self) -> id

Get the NSApplication handle

source

pub fn get_window_native_handle(&self) -> id

Get the NSWindow handle

source

pub unsafe fn run(&self)

Start the NSApplication and activate it ignoring other apps so it comes to front.

Safety

All the FFI functions are unsafe.

source

pub unsafe fn stop(&self)

Stop the NSApplication run loop.

Safety

All the FFI functions are unsafe.

source

pub unsafe fn create_webview(&self) -> DarwinWKWebView

Create a webview that has this app window’s frame.

Safety

All the FFI functions are unsafe.

source

pub unsafe fn set_webview<'a>(&'a self, webview: &'a DarwinWKWebView)

Set the content view of the main window to a certain webview

Safety

All the FFI functions are unsafe.

Trait Implementations§

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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, U> TryFrom<U> for Twhere 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 Twhere 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.