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§
Sourcefn launch(&self, host: &Host) -> impl Future<Output = Result<()>> + Send
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.
Sourcefn run(
&self,
host: &Host,
artifact: Artifact,
options: RunOptions,
) -> impl Future<Output = Result<Running, FailToRun>> + Send
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.
Sourcefn scan(host: &Host) -> impl Future<Output = Result<Vec<Self>>> + Send
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 returnsvec![Local]AppleSimulator::scan()→ usessimctl listAndroidDevice::scan()→ usesadb devices
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".