EmulatorContext

Trait EmulatorContext 

Source
pub trait EmulatorContext: Sized {
    // Required methods
    fn cmd_name(&self) -> String;
    fn args(&self) -> Vec<String>;
    fn env(&self) -> Vec<(String, String)>;
    fn working_dir(&self) -> Utf8PathBuf;
    fn prepare(&mut self) -> Result<(), Error>;

    // Provided method
    fn run(self) -> Result<Output, Error> { ... }
}
Expand description

Behavior used to run an emulator.

Required Methods§

Source

fn cmd_name(&self) -> String

Returns the name of the base command to be executed.

Typically this is the executable file of the emulator (e.g. BizHawk.exe or fceux.exe).

If the executable is a linux binary in the working-directory, be sure to use ./cmd_name rather than just cmd_name.

Source

fn args(&self) -> Vec<String>

Returns a list of arguments to be passed to Command::args.

Source

fn env(&self) -> Vec<(String, String)>

Returns a list of environment variables to be passed to Command::envs.

Source

fn working_dir(&self) -> Utf8PathBuf

Returns the path to the working directory intended for the command’s child process.

Refer to Command::current_dir for more details.

Source

fn prepare(&mut self) -> Result<(), Error>

Perform any file copying or final checks to ensure context is ready for running.

Returns an error if preparation failed.

Provided Methods§

Source

fn run(self) -> Result<Output, Error>

Creates and executes a Command and returns the output result.

Default trait implementation simply calls run.

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§