Files
archived-tauri-vscode/snippets/rust.json
Amr Bashir f85fc5c174 feat: provide schema for config based on tauri-build version (#162)
* feat: provide schema for config based on cli version

* fallback to latest release

* enable commented code

* get schema based on tauri-build version

* change url

* handle schema get request error

* Update versioned-schema.md

* Update extension.ts
2022-09-19 15:08:43 +02:00

31 lines
1.1 KiB
JSON

{
"Create a tauri command": {
"prefix": ["command", "#[tauri::command]", "#[command]"],
"body": [
"#[tauri::command]",
"async fn ${1:command_name}<R: Runtime>(app: tauri::AppHandle<R>, window: tauri::Window<R>) -> Result<(), String> {",
" Ok(())",
"}"
],
"description": "Communicate between the UI and the Rust code"
},
"Create a stateful tauri command": {
"prefix": ["command", "#[tauri::command]", "#[command]"],
"body": [
"#[derive(Default)]",
"struct MyState {",
" s: std::sync::Mutex<String>,",
" t: std::sync::Mutex<std::collections::HashMap<String, String>>,",
"}",
"// remember to call `.manage(MyState::default())`",
"#[tauri::command]",
"async fn ${1:command_name}(state: tauri::State<'_, MyState>) -> Result<(), String> {",
" *state.s.lock().unwrap() = \"new string\".into();",
" state.t.lock().unwrap().insert(\"key\".into(), \"value\".into());",
" Ok(())",
"}"
],
"description": "Communicate between the UI and the Rust code"
}
}