tauri-apps / tauri-apps/tauri-docs
[feat] Deeply Rename Properties before/after invoke
Nobody has claimed this yet.
- Dominant language
- MDX
- Stars
- 1.1k
- Forks
- 887
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 48
Description
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:
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
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Tauri invoke documentation entry point and the linked Serde rename guide. Determine whether the documentation should recommend Serde or describe a supported deep case-conversion approach, including nested objects and arrays; done means the chosen guidance is documented clearly with a matching example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, rust, tauri
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100