1#![deny(unused_imports)]
2
3use super::x_win_struct::{
4 icon_info::IconInfo, process_info::ProcessInfo, usage_info::UsageInfo, window_info::WindowInfo,
5 window_position::WindowPosition,
6};
7
8use super::result::Result;
9
10pub trait Api {
11 fn get_active_window(&self) -> Result<WindowInfo>;
15
16 fn get_open_windows(&self) -> Result<Vec<WindowInfo>>;
20
21 fn get_app_icon(&self, window_info: &WindowInfo) -> Result<IconInfo>;
25
26 fn get_browser_url(&self, window_info: &WindowInfo) -> Result<String>;
30}
31
32pub fn os_name() -> String {
36 #[cfg(target_os = "windows")]
37 {
38 r#"win32"#.to_owned()
39 }
40
41 #[cfg(target_os = "linux")]
42 {
43 r#"linux"#.to_owned()
44 }
45
46 #[cfg(target_os = "macos")]
47 {
48 r#"darwin"#.to_owned()
49 }
50}
51
52pub fn empty_entity() -> WindowInfo {
53 WindowInfo {
54 id: 0,
55 os: os_name(),
56 title: String::from(""),
57 position: WindowPosition {
58 x: 0,
59 y: 0,
60 width: 0,
61 height: 0,
62 is_full_screen: false,
63 },
64 info: ProcessInfo {
65 process_id: 0,
66 path: String::from(""),
67 name: String::from(""),
68 exec_name: String::from(""),
69 },
70 usage: UsageInfo { memory: 0 },
71 }
72}
73
74pub fn empty_icon() -> IconInfo {
75 IconInfo {
76 data: String::from(""),
77 height: 0,
78 width: 0,
79 }
80}