use crate::{RunControl, RunFrame, RunPhase, RunStep, RuntimeTick};
#[doc = crate::_tags!(runtime)]
#[doc = crate::_doc_meta!{location("run")}]
pub trait RunApp {
type Event;
type Error;
fn run_step(&mut self, step: RunStep<'_, Self::Event>) -> Result<RunControl, Self::Error>;
}
#[doc = crate::_tags!(runtime)]
#[doc = crate::_doc_meta!{location("run")}]
pub trait RunBackend {
type Event;
type Error;
type Context<'a>
where
Self: 'a;
fn collect_events(&mut self, out: &mut [Self::Event]) -> Result<usize, Self::Error>;
fn context(&mut self) -> Self::Context<'_>;
fn frame<'a>(
&'a mut self,
tick: RuntimeTick,
phase: RunPhase,
events: &'a [Self::Event],
) -> RunFrame<'a, Self::Event, Self::Context<'a>>
where
Self: Sized,
{
RunFrame::from_parts(tick, phase, events, self.context())
}
}
#[doc = crate::_tags!(runtime)]
#[doc = crate::_doc_meta!{location("run")}]
pub trait RunRender<S: ?Sized, E = (), C = ()> {
type Output<'a>
where
Self: 'a,
E: 'a,
S: 'a;
type Error;
fn run_render<'a>(
&'a mut self,
frame: &mut RunFrame<'a, E, C>,
scene: &'a S,
) -> Result<Self::Output<'a>, Self::Error>;
}
#[doc = crate::_tags!(runtime)]
#[doc = crate::_doc_meta!{location("run")}]
pub trait RunPresent<E = (), C = ()> {
type Input<'a>
where
Self: 'a,
E: 'a;
type Output;
type Error;
fn run_present<'a>(
&'a mut self,
frame: &mut RunFrame<'a, E, C>,
input: Self::Input<'a>,
) -> Result<Self::Output, Self::Error>;
}