Echo Writes Code

mod.rs

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
#[cfg(target_os = "macos")]
pub mod appkit;

#[cfg(target_os = "windows")]
pub mod windows;

#[cfg(all(target_os = "unknown", target_family = "wasm"))]
pub mod html;

use crate::errors::{ Result };

pub trait ApplicationDriver {
  fn on_ready(&mut self) {
  }
}

pub fn run<D: ApplicationDriver + 'static>(delegate: D) -> Result<()> {
  #[cfg(target_os = "macos")]
  let result = appkit::run(delegate);

  #[cfg(target_os = "windows")]
  let result = windows::run(delegate);

  #[cfg(all(target_os = "unknown", target_family = "wasm"))]
  let result = html::run(delegate);

  result
}

pub fn quit() -> Result<()> {
  #[cfg(target_os = "macos")]
  let result = appkit::quit();

  #[cfg(target_os = "windows")]
  let result = windows::quit();

  #[cfg(all(target_os = "unknown", target_family = "wasm"))]
  let result = html::quit();

  result
}