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
mod windows;
use tauri::{
  plugin::{Builder, TauriPlugin},
  Runtime,
};

// the plugin custom command handlers if you choose to extend the API:

#[tauri::command]
// this will be accessible with `invoke('plugin:awesome|initialize')`.
// where `awesome` is the plugin name.
fn initialize() {}

#[tauri::command]
// this will be accessible with `invoke('plugin:printer|get_printers')`.
fn get_printers() -> String {
  if cfg!(windows) {
      return windows::get_printers();
  }

  panic!("Unsupported OS");
}

pub fn init<R: Runtime>() -> TauriPlugin<R> {
  Builder::new("printer")
    .invoke_handler(tauri::generate_handler![initialize, get_printers])
    .build()
}