# conduit-derive
[](https://crates.io/crates/conduit-derive)
[](https://docs.rs/conduit-derive)
[](https://github.com/userFRM/tauri-conduit/actions/workflows/ci.yml)
[](https://github.com/userFRM/tauri-conduit#license)
Proc macros for [conduit-core](https://crates.io/crates/conduit-core): `#[derive(Encode, Decode)]`, `#[command]`, and `handler!()`.
Part of the [tauri-conduit](https://github.com/userFRM/tauri-conduit) workspace (v2.1.0).
## Usage
### Binary codec
```rust
use conduit_derive::{Encode, Decode};
#[derive(Encode, Decode)]
struct MarketTick {
timestamp: i64,
price: f64,
volume: f64,
side: u8,
}
// 25 bytes on the wire. No schema, no parsing.
```
Supported field types: `u8`-`u64`, `i8`-`i64`, `f32`, `f64`, `bool`, `Vec<u8>`, `String`, `Bytes`.
The `Decode` derive automatically generates a `MIN_SIZE` constant for upfront bounds checking.
### Command handlers
```rust
use conduit::{command, handler};
#[command]
fn greet(name: String) -> String {
format!("Hello, {name}!")
}
// Register with handler!() macro:
// .handler("greet", handler!(greet))
```
`#[command]` supports named parameters, `State<T>` injection, `AppHandle`, `Window`/`Webview` injection, `Result<T, E>` returns, and `async` functions.
See the [workspace README](https://github.com/userFRM/tauri-conduit) for full documentation.
## License
Licensed under either of [MIT](https://github.com/userFRM/tauri-conduit/blob/master/LICENSE-MIT) or [Apache-2.0](https://github.com/userFRM/tauri-conduit/blob/master/LICENSE-APACHE) at your option.