i need to get serial number and other identifiers in tauri and i got this rust api but i cant find a away to send the serial number to javascript using invoke
Rust: https://github.com/Taptiive/machineid-rs
here is what i have tried
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use machineid_rs::{Encryption, IdBuilder};
use tauri::{Manager, Window};
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
#[tauri::command]
async fn close_splashscreen(window: Window) {
let mut builder = IdBuilder::new(Encryption::SHA256);
use machineid_rs::HWIDComponent;
builder
.add_component(HWIDComponent::SystemID)
.add_component(HWIDComponent::CPUCores)
.add_component(HWIDComponent::DriveSerial);
let hwid = builder.build("mykey").unwrap();
//println!("{}", HWIDComponent::DriveSerial);
// Close splashscreen
window
.get_window("splashscreen")
.expect("no window labeled 'splashscreen' found")
.close()
.unwrap();
// Show main window
window
.get_window("main")
.expect("no window labeled 'main' found")
.show()
.unwrap();
}
/*
fn greet(name: &str) -> String {
format!("Hello, {}! You've been greeted from Rust!", name)
}
*/
fn main() {
tauri::Builder::default()
/*
.setup(|app| {
let splashscreen_window = app.get_window("splashscreen").unwrap();
let main_window = app.get_window("main").unwrap();
// we perform the initialization code on a new task so the app doesn't freeze
tauri::async_runtime::spawn(async move {
// initialize your app here instead of sleeping :)
println!("Initializing...");
std::thread::sleep(std::time::Duration::from_secs(2));
println!("Done initializing.");
// After it's done, close the splashscreen and display the main window
//splashscreen_window.close().unwrap();
main_window.hide().unwrap();
});
Ok(())
})
*/
.invoke_handler(tauri::generate_handler![close_splashscreen])
.run(tauri::generate_context!())
.expect("failed to run app");
}
waiting for your answers, am still learning Rust