27 lines
660 B
Rust
27 lines
660 B
Rust
|
|
use std::error::Error;
|
||
|
|
|
||
|
|
use serde::de::DeserializeOwned;
|
||
|
|
use serde::{Deserialize, Serialize};
|
||
|
|
|
||
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
||
|
|
pub struct CoreTickInput<W, A> {
|
||
|
|
pub world: W,
|
||
|
|
pub actions: Vec<A>,
|
||
|
|
}
|
||
|
|
|
||
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
||
|
|
pub struct CoreTickOutput<W> {
|
||
|
|
pub world: W,
|
||
|
|
}
|
||
|
|
|
||
|
|
pub trait Core {
|
||
|
|
type World: Serialize + DeserializeOwned;
|
||
|
|
type Action: Serialize + DeserializeOwned;
|
||
|
|
type Error: Error + Send + Sync + 'static;
|
||
|
|
|
||
|
|
fn tick(
|
||
|
|
&mut self,
|
||
|
|
input: CoreTickInput<Self::World, Self::Action>,
|
||
|
|
) -> Result<CoreTickOutput<Self::World>, Self::Error>;
|
||
|
|
}
|