Skip to main content

Device

Trait Device 

Source
pub trait Device: Sized + Send {
    // Required methods
    fn name(&self) -> &str;
    fn launch(&self, host: &Host) -> impl Future<Output = Result<()>> + Send;
    fn run(
        &self,
        host: &Host,
        artifact: Artifact,
        options: RunOptions,
    ) -> impl Future<Output = Result<Running, FailToRun>> + Send;
    fn scan(host: &Host) -> impl Future<Output = Result<Vec<Self>>> + Send;
}
Expand description

Trait representing a device (e.g., emulator, simulator, physical device)

Devices are decoupled from platforms - a device just knows how to execute artifacts. The same device can be used with different backends (e.g., Local device works with both Apple and GTK4 backends on macOS).

Each device type knows how to scan for available devices of its kind via the associated scan() function.

Required Methods§

Source

fn name(&self) -> &str

Human-readable name for display purposes.

Source

fn launch(&self, host: &Host) -> impl Future<Output = Result<()>> + Send

Launch the device emulator or simulator.

If the device is a physical device or local machine, this should do nothing.

Source

fn run( &self, host: &Host, artifact: Artifact, options: RunOptions, ) -> impl Future<Output = Result<Running, FailToRun>> + Send

Run the given artifact on the device with the specified options.

Source

fn scan(host: &Host) -> impl Future<Output = Result<Vec<Self>>> + Send

Scan for available devices of this type on host.

Each device type knows how to discover its own kind:

  • Local::scan() → always returns vec![Local]
  • AppleSimulator::scan() → uses simctl list
  • AndroidDevice::scan() → uses adb devices

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§