33 lines
790 B
Rust
33 lines
790 B
Rust
pub mod ui;
|
|
use kifu_core::{CoreApp, CoreRequest, CoreResponse};
|
|
use std::sync::Arc;
|
|
use tokio::runtime::Runtime;
|
|
|
|
#[derive(Clone)]
|
|
pub struct CoreApi {
|
|
pub gtk_tx: gtk::glib::Sender<CoreResponse>,
|
|
pub rt: Arc<Runtime>,
|
|
pub core: CoreApp,
|
|
}
|
|
|
|
impl CoreApi {
|
|
pub fn dispatch(&self, request: CoreRequest) {
|
|
self.rt.spawn({
|
|
let gtk_tx = self.gtk_tx.clone();
|
|
let core = self.core.clone();
|
|
async move { gtk_tx.send(core.dispatch(request).await) }
|
|
});
|
|
}
|
|
}
|
|
|
|
pub fn perftrace<F, A>(trace_name: &str, f: F) -> A
|
|
where
|
|
F: FnOnce() -> A,
|
|
{
|
|
let start = std::time::Instant::now();
|
|
let result = f();
|
|
let end = std::time::Instant::now();
|
|
println!("[Trace: {}] {:?}", trace_name, end - start);
|
|
return result;
|
|
}
|