Skip to main content

Driver

Trait Driver 

Source
pub trait Driver {
    // Required methods
    fn start(&mut self) -> Result<(), CnResult>;
    fn run(self: Box<Self>) -> Result<(), CnResult>;
    fn into_world(self: Box<Self>) -> World;
}
Expand description

A loop that runs a World.

App is the implementation with nothing underneath it: a fixed virtual timestep, no window, and no wall clock. A host that has an operating system implements this over its own loop, and what such a host adds – pacing a frame against a display, following real elapsed time, catching a signal – stays on its side of the seam.

run reports whether the run failed rather than how it ended. A StepResult is a system’s verdict on its own tick, and a host ends a run for reasons no system sees, so a driver that reported one would owe readings for them.

run consumes the driver, since a run ends the world it was handed; into_world is the other way out, for a caller that wants the world back instead of run.

Required Methods§

Source

fn start(&mut self) -> Result<(), CnResult>

Build the world’s systems and run their init.

Source

fn run(self: Box<Self>) -> Result<(), CnResult>

Run the world until it ends.

Source

fn into_world(self: Box<Self>) -> World

Take the world back instead of running it.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§