iced_wry 0.1.0

Embed a WRY webview as a child window inside an Iced application
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! JS->Rust IPC channel bridging `window.ipc.postMessage()` to the app.

use std::sync::{Arc, Mutex};

use futures::channel::mpsc;

#[derive(Debug, Clone)]
pub struct IpcMessage {
    pub body: String,
}

pub(crate) type IpcSender = mpsc::UnboundedSender<IpcMessage>;
pub(crate) type IpcReceiver = Arc<Mutex<Option<mpsc::UnboundedReceiver<IpcMessage>>>>;

pub(crate) fn ipc_channel() -> (IpcSender, IpcReceiver) {
    let (tx, rx) = mpsc::unbounded();
    (tx, Arc::new(Mutex::new(Some(rx))))
}