Open bradleat opened 1 month ago
I have to manually rename objects properties from camelCase to snake_case to pass them to tauri invoke (also on the way back).
For instance, if I have rust code like this:
struct Example { pub one_thing: f64; } #[tauri::command] fn echo_example(example_thing: Example) => Result<Example, String> { OK(example_thing) }
Then in javascript I have to do this:
response = await invoke('echo_example`, { exampleThing: { one_thing: 10.5 } }) // format response again formattedResponse = { oneThing: response.one_thing }
You can imagine this is annnoying for deeply nested structs, objects, esp involving arrays/vecs
I'd like to have the case conversion deeply applied.
https://serde.rs/attr-rename.html
Perhaps the Usage of Serde should be suggested in the documentation. No response
Just add #[serde(rename_all = "camelCase")] on your struct
#[serde(rename_all = "camelCase")]
I believe this is more of a documentation issue, so I will just move to tauri-docs
Describe the problem
I have to manually rename objects properties from camelCase to snake_case to pass them to tauri invoke (also on the way back).
For instance, if I have rust code like this:
Then in javascript I have to do this:
You can imagine this is annnoying for deeply nested structs, objects, esp involving arrays/vecs
Describe the solution you'd like
I'd like to have the case conversion deeply applied.
Alternatives considered
https://serde.rs/attr-rename.html
Additional context
Perhaps the Usage of Serde should be suggested in the documentation. No response