Game

Trait Game 

Source
pub trait Game {
    // Required methods
    fn new(args: Args) -> Self;
    fn start(&mut self);
    fn do_loop(&mut self) -> Result<i32, Box<dyn Error>>;
    fn finish(self);
}
Expand description

Default methods for a terminal-based game.

Required Methods§

Source

fn new(args: Args) -> Self

Used to transform the arguments, if any, into the game object.

Source

fn start(&mut self)

Starts the game. This is called once at the beginning by the mint_cli.

Source

fn do_loop(&mut self) -> Result<i32, Box<dyn Error>>

What should be done in a loop. This is called in a loop by the mint_cli until an error occurs, or a code other than GAME_ONGOING is returned.

Source

fn finish(self)

Finishes the game. Anything to be cleaned up/done once at the end of the game loop should be done here.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§