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

34 lines
658 B
Rust
Raw Normal View History

use crate::types::AppState;
2023-03-24 13:59:04 +00:00
use crate::ui::{playing_field, PlayingFieldView};
use std::sync::{Arc, RwLock};
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) {}
}