#Use enums in tauri::command
19 messages · Page 1 of 1 (latest)
Sorry to hijack this post. How would I supply an enum that takes another enum as an argument to the invoke call in js?
Do I need to provide the json string representation?
please give some example for better understand xD
pub enum HWRequest {
Hello,
ReqState,
Initialise,
Uninitialise,
Cmd(HWCmd)
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub enum HWCmd {
Laser(usize, LaserCmd),
Test,
}```
fn hw_request(hwrequest: HWRequest, iswrapper: State<ISWrapper>) -> Result<(), Error> {
///
const cmdstr = "Cmd(Test)"
await invoke("hw_request", {hwrequest: cmdstr});
}```
I'd like to be able to do something like this in js.
But I suspect I need to craft the json in js.
by default it's:
async function laser_on(idx) {
await invoke("hw_request", {hwrequest: {"Cmd": "Test"});
}
for things like this, you could serialize it and then look how serde do, xD
and this may helps you.