tauri-apps / tauri-apps/tauri-docs

[feat] Deeply Rename Properties before/after invoke

Open
#2,732 1 comment 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.