tek/crates/tek_core/src/engine.rs
2024-09-06 21:52:23 +03:00

52 lines
960 B
Rust

use crate::*;
use std::ops::{Add, Sub};
use std::cmp::{Ord, Eq, PartialEq};
/// Entry point for main loop
pub trait App<T: Engine> {
fn run (self, context: T) -> Usually<T>;
}
pub trait Number: Send + Sync + Copy
+ Add<Self, Output=Self>
+ Sub<Self, Output=Self>
+ Ord + PartialEq + Eq {}
impl<T> Number for T where
T: Send + Sync + Copy
+ Add<Self, Output=Self>
+ Sub<Self, Output=Self>
+ Ord + PartialEq + Eq
{}
/// Platform backend.
pub trait Engine: Sized {
fn setup (&mut self) -> Usually<()> { Ok(()) }
fn exited (&self) -> bool;
fn teardown (&mut self) -> Usually<()> { Ok(()) }
/// Unit of distance.
type Unit: Number;
type HandleInput;
type Handled;
type RenderInput;
type Rendered;
}
pub trait HandleContext {}
pub trait RenderContext {}
submod! {
collect
component
exit
focus
handle
keymap
layered
layout
render
split
}