I have a small tauri app that on the JS part sends some data back to the rust backend using the invoke
method.
The method works, most of the data arrives to the backend. The data itself contains a map, which does not arrive though.
const [details, setDetails] = useState({
name: "",
country: "",
address: "",
items: new Map<String, number>
})
...
async function handleSubmit(e: any) {
e.preventDefault()
console.log(details)
await invoke('submit_new_customer', { details }).then((submitted) => { ... })
}
The logged out details:
{
name: "Alfred Gustavsson",
country: "Norway",
address: "Exapmle street",
items: Map(1) {'3' => 1}
}
The backend:
#[derive(Serialize, Deserialize, Debug)]
struct NewCustomerInput {
name: String,
country: String,
address: Option<String>,
items: HashMap<String, usize>
}
#[tauri::command]
fn submit_new_customer(details: NewCustomerInput) -> bool {
println!("{:?}", details);
...
From the print I can see that the items is {}
. How can I setup my struct to accept the Map from the fronted?