| Crates.io | wry_cmd |
| lib.rs | wry_cmd |
| version | 0.1.3 |
| created_at | 2025-07-25 14:45:50.499867+00 |
| updated_at | 2025-07-25 19:11:41.683348+00 |
| description | Facade crate combining wry_cmd_core (runtime) and wry_cmd_macro (IPC-command registration) for Wry. |
| homepage | https://github.com/KitsuneDev/wry_cmd |
| repository | https://github.com/KitsuneDev/wry_cmd |
| max_upload_size | |
| id | 1767727 |
| size | 82,500 |
Tauri-style #[command] macro and command system for wry, supporting async Rust functions and front-end integration via a custom protocol.
#[command] macro for both async fn and fnwith_asynchronous_custom_protocol
use wry_cmd::{command, use_wry_cmd_protocol};
#[derive(serde::Deserialize, Default)]
struct GreetArgs {
name: String,
}
#[derive(serde::Serialize, Default)]
struct GreetReply {
message: String,
}
#[command]
fn greet(args: GreetArgs) -> GreetReply {
println!("Greet command called with: {:?}", args.name);
GreetReply {
message: format!("Hello, {}!", args.name),
}
}
let wv = WebViewBuilder::new()
.with_asynchronous_custom_protocol("proto".to_string(), use_wry_cmd_protocol!("proto"))
.build(&window)
.expect("Failed to build WebView");
Then in JS:
async function sendGreet() {
const name = document.getElementById("name").value;
// You can use `http://proto.greet` for Windows compatibility
// or `proto://greet` for other platforms.
const res = await fetch(`http://proto.greet`, {
method: "POST",
body: JSON.stringify({ name }),
headers: { "Content-Type": "application/json" },
});
const data = await res.json();
document.getElementById("response").textContent = data.error
? "Error: " + data.error
: data.message;
}
Please note that AI has been used in order to properly document this crate.