use super::{Error, Metadata};
#[derive(Clone, Debug)]
pub enum Device {
IOS {
device: simctl::Device,
runtime: simctl::list::Runtime,
device_type: simctl::list::DeviceType,
},
}
impl Device {
pub fn open_url(&self, url: &str) -> Result<(), Error> {
match self {
Device::IOS { device, .. } => device.open_url(url).map_err(|error| Error::IOS(error)),
}
}
pub fn screenshot(&self) -> Result<Vec<u8>, Error> {
match self {
Device::IOS { device, .. } => device
.io()
.screenshot(
simctl::io::ImageType::Png,
simctl::io::Display::Internal,
simctl::io::Mask::Ignored,
)
.map_err(|error| Error::IOS(error)),
}
}
pub fn metadata(&self) -> Metadata {
match self {
Device::IOS {
device_type,
runtime,
..
} => Metadata {
device: Some(device_type.name.clone()),
os: Some(runtime.name.clone()),
os_version: Some(runtime.version.clone()),
..Default::default()
},
}
}
}