'Tauri Rust Invoke and return to frontend issues

I have invoked a function from my frontend to my backend. It works however I want to return results back to frontend and all I get is null

#[tauri::command]
fn get_midi_device_list() {
    // "Hello from Rust!".into()
    println!("System destinations:");

    for (i, destination) in coremidi::Destinations.into_iter().enumerate() {
        let display_name = get_display_name(&destination);
        println!("[{}] {}", i, display_name);

    }
}


Solution 1:[1]

the tauri github page has many examples of commands with results. maybe one of them will work for you.

for instance:

#[command]
fn simple_command_with_result(argument: String) -> Result<String, MyError> {
  println!("{}", argument);
  (!argument.is_empty())
    .then(|| argument)
    .ok_or(MyError::FooError)
}

Solution 2:[2]

Your function does not return anything (other than ()). So maybe try to actually return a value?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 svenwulf
Solution 2 hkBst