mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
add Input and Output traits to Engine
This commit is contained in:
parent
c2e91fb432
commit
d9535b707f
2 changed files with 35 additions and 18 deletions
|
|
@ -7,21 +7,29 @@ pub trait App<T: Engine> {
|
|||
|
||||
/// Platform backend.
|
||||
pub trait Engine: Send + Sync + Sized {
|
||||
fn setup (&mut self) -> Usually<()> { Ok(()) }
|
||||
fn exited (&self) -> bool;
|
||||
fn teardown (&mut self) -> Usually<()> { Ok(()) }
|
||||
type Input: Input<Self>;
|
||||
type Handled;
|
||||
type Output: Output<Self>;
|
||||
|
||||
/// Unit of distance.
|
||||
type Unit: Number;
|
||||
type Area: Area<Self::Unit> + From<[Self::Unit;4]> + Debug;
|
||||
type Size: Size<Self::Unit> + From<[Self::Unit;2]> + Debug;
|
||||
|
||||
type Input;
|
||||
type Handled;
|
||||
type Output: RenderTarget<Self>;
|
||||
fn setup (&mut self) -> Usually<()> { Ok(()) }
|
||||
fn exited (&self) -> bool;
|
||||
fn teardown (&mut self) -> Usually<()> { Ok(()) }
|
||||
}
|
||||
|
||||
pub trait RenderTarget<E: Engine> {
|
||||
pub trait Input<E: Engine> {
|
||||
type Event;
|
||||
fn event (&self)
|
||||
-> Self::Event;
|
||||
fn is_done (&self)
|
||||
-> bool;
|
||||
fn done (&self);
|
||||
}
|
||||
|
||||
pub trait Output<E: Engine> {
|
||||
fn area (&self)
|
||||
-> E::Area;
|
||||
fn area_mut (&mut self)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue