rust_droid/
models.rs

1use crate::common::point::Point;
2use std::path::{Path, PathBuf};
3
4/// Represents the target of an operation, which can be a precise coordinate
5/// or an image that needs to be located on the screen.
6#[derive(Debug, Clone)]
7pub enum Target {
8    /// An absolute coordinate on the screen.
9    Point(Point),
10    /// The path to an image file to be used as a template for visual search.
11    Image(PathBuf),
12}
13
14impl From<Point> for Target {
15    fn from(point: Point) -> Self {
16        Target::Point(point)
17    }
18}
19
20impl From<PathBuf> for Target {
21    fn from(path: PathBuf) -> Self {
22        Target::Image(path)
23    }
24}
25
26impl From<&Path> for Target {
27    fn from(path: &Path) -> Self {
28        Target::Image(path.to_path_buf())
29    }
30}
31
32impl From<&str> for Target {
33    fn from(path: &str) -> Self {
34        Target::Image(PathBuf::from(path))
35    }
36}
37
38/// An enumeration of common Android key codes.
39///
40/// These are sent to the device using `input keyevent`.
41#[derive(Debug, Clone, Copy)]
42#[repr(i32)]
43pub enum KeyCode {
44    Home = 3,
45    Back = 4,
46    Enter = 66,
47}