use std::sync::Mutex;

use tauri::Manager;

// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
pub mod app_error;
pub mod commands;
pub mod services;
pub mod app_state;

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
    tauri::Builder::default()
        .plugin(tauri_plugin_dialog::init())
        .plugin(tauri_plugin_shell::init())
        .invoke_handler(tauri::generate_handler![
            commands::set_complete,
            commands::command_open_file,
            commands::command_close_file,
            commands::command_get_file_pe_node_tree_data,
            commands::command_get_pe_data_dos_header,
            commands::command_get_pe_data_nt_header,
            commands::command_get_pe_data_file_header,
            commands::command_get_pe_data_optional_header,
            commands::command_get_pe_data_section_headers,
            commands::command_get_pe_data_import_directory,
            commands::command_write_data,
            commands::command_write_data_list,
            commands::command_add_section,
            commands::command_test,
        ])
        .setup(|app| {
            app.manage(Mutex::new(app_state::AppState::default()));
            Ok(())
        })
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}
