summaryrefslogtreecommitdiffstats
path: root/src/gui.rs
blob: 1d5281eff5139553b669092782f9e361acb2a03b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use std::fmt::Debug;

use anyhow::Error;
use anyhow::Result;
use web_view::WVResult;
use web_view::WebView;

use crate::cli::*;
use crate::types::util::*;

pub fn run_gui(adr: String) -> Result<()> {
    let webview_content = web_view::Content::Url(format!("http://{}", adr));

    web_view::builder()
        .title("My Project")
        .content(webview_content)
        .resizable(true)
        .debug(true)
        .user_data(())
        .invoke_handler(invoke_handler)
        .build()
        .map_err(Error::from)?
        .run()
        .map_err(Error::from)
}

fn invoke_handler<T: Debug>(webview: &mut WebView<T>, s: &str) -> WVResult {
    debug!("invoke-handler: {:?}, {:?}", webview, s);
    Ok(())
}