1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! IPC bridge for WebView ↔ Rust communication
//!
//! This crate provides the message handling layer between the React UI
//! (running in a WebView) and Rust application logic. It implements
//! JSON-RPC 2.0 style request/response handling with typed message contracts.
//!
//! # Architecture
//!
//! - **ParameterHost** trait: Abstracts parameter storage (desktop POC, plugin, etc.)
//! - **IpcHandler**: Dispatches JSON-RPC requests to appropriate handlers
//! - **BridgeError**: Typed error handling with conversion to IPC error codes
//!
//! # Example
//!
//! ```rust,no_run
//! use wavecraft_bridge::{IpcHandler, ParameterHost, BridgeError};
//! use wavecraft_protocol::{MeterFrame, ParameterInfo};
//!
//! // Implement ParameterHost for your application state
//! struct MyApp;
//!
//! impl ParameterHost for MyApp {
//! fn get_parameter(&self, id: &str) -> Option<ParameterInfo> {
//! // Implementation
//! None
//! }
//!
//! fn set_parameter(&self, id: &str, value: f32) -> Result<(), BridgeError> {
//! // Implementation
//! Ok(())
//! }
//!
//! fn get_all_parameters(&self) -> Vec<ParameterInfo> {
//! // Implementation
//! vec![]
//! }
//!
//! fn get_meter_frame(&self) -> Option<MeterFrame> {
//! // Implementation
//! None
//! }
//!
//! fn request_resize(&self, _width: u32, _height: u32) -> bool {
//! // Implementation
//! false
//! }
//! }
//!
//! // Create handler
//! let handler = IpcHandler::new(MyApp);
//!
//! // Handle incoming JSON from WebView
//! let request_json = r#"{"jsonrpc":"2.0","id":1,"method":"ping"}"#;
//! let response_json = handler.handle_json(request_json);
//! ```
// Re-export key types for convenience
pub use BridgeError;
pub use IpcHandler;
pub use ParameterHost;
pub use ;
pub use ;
// Re-export protocol types used in bridge API
pub use ;