conduit-core
Binary IPC core for Tauri v2: codec, router, ring buffer, and ordered queue.
Part of the tauri-conduit workspace (v2.1.1).
Features
- 11-byte frame codec with
Encode/Decodetraits for zero-parse binary serialization Bytesnewtype for efficient bulkVec<u8>encode/decodeMIN_SIZEconstant onDecodefor upfront bounds checking (derived automatically)- Synchronous router for named command handlers (raw, JSON, and binary)
- In-process ring buffer (
RingBuffer) with lossy back-pressure and preformatted wire buffer (drain_all is single memcpy) - Ordered queue (
Queue) with guaranteed delivery, backpressure, and preformatted wire buffer - Channel abstraction (
ChannelBuffer) unifying lossy and ordered channels - Overflow guards -- u32 truncation checks, frame_count cap, checked_add for 32-bit safety
Key Types
| Type | Purpose |
|---|---|
Router |
Named synchronous command registry (register, register_json, register_binary, call) |
RingBuffer |
Thread-safe lossy circular buffer — oldest frames dropped on overflow |
Queue |
Thread-safe ordered buffer — backpressure when full, no data loss |
ChannelBuffer |
Enum wrapping RingBuffer (Lossy) or Queue (Reliable) with a unified push/drain API |
ConduitHandler |
Trait for sync/async command handlers, implemented by #[command]-generated structs |
HandlerResponse |
Enum: Sync(Result<Vec<u8>, Error>) or Async(Pin<Box<dyn Future>>) |
HandlerContext |
Context passed to handlers: app handle + optional webview label |
PushOutcome |
Enum: Accepted(usize) or TooLarge — opt-in via push_checked() |
FrameHeader |
11-byte binary frame header for all conduit messages |
Encode / Decode |
Traits for fixed-layout binary serialization (Decode includes MIN_SIZE constant) |
Bytes |
Newtype for Vec<u8> with efficient bulk encode/decode |
Error |
Error types (UnknownCommand, DecodeFailed, Serialize, UnknownChannel, etc.) |
Usage
use ;
// Raw handler
let router = new;
router.register;
let response = router.call.unwrap;
assert_eq!;
// JSON handler
router.register_json;
// Binary handler (with Encode/Decode types)
// router.register_binary("process", |tick: MarketTick| tick);
Benchmarks
Includes a head-to-head comparison benchmark against JSON (serde):
See the workspace README for full documentation and benchmark numbers.
License
Licensed under either of MIT or Apache-2.0 at your option.