pitwall-tauri 0.1.0

Tauri integration for Pitwall telemetry library
Documentation
//! # Pitwall-Tauri
//!
//! Tauri integration layer for the Pitwall telemetry library.
//!
//! This crate provides minimal, stateless bridges between Pitwall's streaming API
//! and Tauri's IPC channels, plus TypeScript type generation for compile-time
//! type safety between Rust and TypeScript.
//!
//! ## Features
//!
//! - **Stream Mirroring**: Simple `to_channel()` function for any Pitwall stream
//! - **Type Generation**: Export TypeScript bindings from Rust types
//! - **Zero State**: Completely stateless - user manages connection lifecycle
//! - **High Performance**: <1% CPU overhead for 60Hz telemetry streaming
//!
//! ## Quick Start
//!
//! ### 1. Define Your Frame Type
//!
//! ```rust,ignore
//! use pitwall::PitwallFrame;
//! use serde::{Serialize, Deserialize};
//! use specta::Type;
//!
//! #[derive(Debug, Clone, Serialize, Deserialize, Type, PitwallFrame)]
//! struct MyTelemetry {
//!     #[pitwall(name = "Speed")]
//!     speed: f32,
//!
//!     #[pitwall(name = "Gear")]
//!     gear: i32,
//!
//!     #[pitwall(name = "RPM")]
//!     rpm: f32,
//! }
//! ```
//!
//! ### 2. Create Tauri Command
//!
//! ```rust,ignore
//! use tauri::ipc::Channel;
//! use pitwall_tauri::to_channel;
//!
//! #[tauri::command]
//! async fn start_telemetry(
//!     telemetry: Channel<MyTelemetry>,
//!     session: Channel<SessionInfo>,
//! ) -> Result<(), String> {
//!     let conn = Pitwall::connect().await
//!         .map_err(|e| e.to_string())?;
//!
//!     // Spawn telemetry stream
//!     tokio::spawn({
//!         let stream = conn.subscribe::<MyTelemetry>(UpdateRate::Native);
//!         async move {
//!             to_channel(stream, telemetry).await
//!         }
//!     });
//!
//!     // Spawn session updates stream
//!     tokio::spawn({
//!         let stream = conn.session_updates();
//!         async move {
//!             to_channel(stream, session).await
//!         }
//!     });
//!
//!     Ok(())
//! }
//! ```
//!
//! ### 3. Generate TypeScript Bindings
//!
//! ```rust,ignore
//! fn main() {
//!     // Generate TypeScript types (run once during build or manually)
//!     #[cfg(debug_assertions)]
//!     {
//!         tauri_specta::ts::export(
//!             specta::collect_types![start_telemetry],
//!             "../src/bindings.ts"
//!         ).expect("Failed to export TypeScript bindings");
//!     }
//!
//!     tauri::Builder::default()
//!         .invoke_handler(tauri::generate_handler![start_telemetry])
//!         .run(tauri::generate_context!())
//!         .expect("error while running tauri application");
//! }
//! ```
//!
//! ### 4. Use in TypeScript
//!
//! ```typescript
//! import { invoke, Channel } from '@tauri-apps/api/core';
//! import type { MyTelemetry, SessionInfo } from './bindings';
//!
//! const telemetryChannel = new Channel<MyTelemetry>();
//! const sessionChannel = new Channel<SessionInfo>();
//!
//! telemetryChannel.onmessage = (data) => {
//!   console.log(`Speed: ${data.speed}, Gear: ${data.gear}`);
//! };
//!
//! sessionChannel.onmessage = (session) => {
//!   console.log(`Track: ${session.weekend_info.track_name}`);
//! };
//!
//! await invoke('start_telemetry', {
//!   telemetry: telemetryChannel,
//!   session: sessionChannel,
//! });
//! ```

pub mod bridge;

// Re-export Pitwall types for convenience
pub use pitwall::{Pitwall, SessionInfo, UpdateRate, VariableInfo, VariableSchema, VariableType};

// Re-export bridge function as primary API
pub use bridge::to_channel;