1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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()
},
}
}
}