monorepo/kifu/kifu-core/src/api.rs

39 lines
766 B
Rust
Raw Normal View History

use crate::types::AppState;
use crate::ui::playing_field::{playing_field, PlayingFieldView};
use std::{
sync::{Arc, RwLock},
thread,
time::Duration,
};
use tokio::sync::mpsc::{channel, Receiver, Sender};
pub enum Request {
PlayingField,
}
#[derive(Debug)]
pub enum Response {
PlayingFieldView(PlayingFieldView),
}
#[derive(Clone)]
pub struct CoreApp {
state: Arc<RwLock<AppState>>,
}
impl CoreApp {
pub fn new() -> Self {
let state = Arc::new(RwLock::new(AppState::new()));
Self { state }
}
pub async fn dispatch(&self, request: Request) -> Response {
match request {
Request::PlayingField => Response::PlayingFieldView(playing_field()),
}
}
pub async fn run(&self) {}
}