2023-03-23 03:11:56 +00:00
|
|
|
pub mod ui;
|
2023-04-07 01:52:39 +00:00
|
|
|
use kifu_core::{CoreApp, Request, Response};
|
|
|
|
use std::sync::Arc;
|
|
|
|
use tokio::runtime::Runtime;
|
|
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
|
pub struct CoreApi {
|
|
|
|
pub gtk_tx: gtk::glib::Sender<Response>,
|
|
|
|
pub rt: Arc<Runtime>,
|
|
|
|
pub core: CoreApp,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl CoreApi {
|
|
|
|
pub fn dispatch(&self, request: Request) {
|
|
|
|
self.rt.spawn({
|
|
|
|
let gtk_tx = self.gtk_tx.clone();
|
|
|
|
let core = self.core.clone();
|
|
|
|
async move { gtk_tx.send(core.dispatch(request).await) }
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|