#I cannot read all values from an rust command return

12 messages · Page 1 of 1 (latest)

leaden berry
#

Hey,

i have a rust command that returns me a struct of values. The Problem is, that i can only read the name value of its struct after calling it in Typescript. Am i missing something?

i can only get a value from volumes.name, all others give me a undefined in console.log.

Versions:

[build-dependencies]
tauri-build = { version = "1.4.0", features = [] }

[dependencies]
sysinfo = "0.29.7"

Serde imported from tauri

serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.4.0", features = [] }

spare sparrow
#

camel_case

#

What you receive in the javascript end will still have camel_case, so it's be name, then total_space etc

#

The reason being that that's the default way that serde serializes your struct

ebon depot
# spare sparrow `camel_case`

A quick question that is somewhat relevant to the discussion, does Tauri, when passing arguments from frontend code to Rust code, does it convert camelCase to snake_case? I tried using snake_case the first time and it didn't work.

leaden berry
leaden berry
ebon depot
#

I have my app all using snake_case in all invoke function calls.

leaden berry
#

Thats for arguments: Please note, when declaring arguments in Rust using snake_case, the arguments are converted to camelCase for JavaScript.
To use snake_case in JavaScript, you have to declare it in the tauri::command statement

leaden berry