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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
//! # spice-client
//!
//! A pure Rust implementation of the SPICE (Simple Protocol for Independent Computing Environments)
//! client protocol with support for both native and WebAssembly targets.
//!
//! ## Features
//!
//! - **Pure Rust** - No C dependencies, easy to build and integrate
//! - **Async/await** - Modern async API using Tokio for native and wasm-bindgen for WASM
//! - **Cross-platform** - Works on Linux, macOS, Windows, and WebAssembly
//! - **WebAssembly Support** - Run SPICE clients directly in web browsers
//! - **Multiple Channels** - Main, Display, Inputs, and Cursor channels implemented
//! - **Authentication** - RSA-OAEP (Spice ticket) authentication support
//! - **Multi-display** - Support for multiple display surfaces
//! - **Extensible** - Easy to add new channel types
//!
//! ## Quick Start
//!
//! Add this to your `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! spice-client = "0.1.0"
//!
//! # For native builds
//! tokio = { version = "1", features = ["full"] }
//! ```
//!
//! ## Basic Example
//!
//! ```no_run
//! use spice_client::{SpiceClient, SpiceError};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), SpiceError> {
//! // Create a new SPICE client
//! let mut client = SpiceClient::new("localhost".to_string(), 5900);
//!
//! // Connect to the SPICE server
//! client.connect().await?;
//!
//! // The client handles messages internally through channels
//! // You can interact with display, input, and other channels
//!
//! Ok(())
//! }
//! ```
//!
//! ## WebAssembly Example
//!
//! ```ignore
//! use spice_client::{SpiceClient, SpiceError};
//! use wasm_bindgen_futures::spawn_local;
//!
//! fn connect_to_spice() {
//! spawn_local(async {
//! // WebSocket proxy URL (ws:// or wss://)
//! let mut client = SpiceClient::new(
//! "ws://localhost:8080/spice".to_string(),
//! 0 // Port is included in WebSocket URL
//! );
//!
//! if let Err(e) = client.connect().await {
//! web_sys::console::error_1(&format!("Connection failed: {:?}", e).into());
//! }
//! });
//! }
//! ```
//!
//! ## Architecture
//!
//! The library is organized into several modules:
//!
//! - **`protocol`** - SPICE protocol message definitions and serialization
//! - **`client`** - Native client implementation using Tokio
//! - **`wasm_bindings`** - WebAssembly client using browser APIs
//! - **`channels`** - Individual channel implementations (Main, Display, Inputs, Cursor)
//! - **`error`** - Error types and result definitions
//!
//! ## Supported Channels
//!
//! - **Main Channel** - Connection setup, mouse modes, agent communication
//! - **Display Channel** - Screen updates, drawing commands, video streaming
//! - **Inputs Channel** - Keyboard and mouse input
//! - **Cursor Channel** - Hardware cursor updates
//!
//! ## Current Limitations
//!
//! This library is functional but still under active development. Current limitations include:
//!
//! - **No audio support** - Playback and Record channels not implemented
//! - **No USB redirection** - USB channel not implemented
//! - **No clipboard sharing** - Agent clipboard integration not implemented
//! - **Limited compression** - Only ZLIB compression supported (no LZ4)
//! - **No TLS encryption** - Only unencrypted connections supported
//! - **WebSocket proxy required for WASM** - Cannot connect directly to SPICE TCP ports from browsers
//! - **Partial drawing commands** - Some complex QXL drawing operations not fully implemented
//!
//! ## Platform-Specific Considerations
//!
//! ### Native Builds
//! - Full Tokio runtime required
//! - Direct TCP connection to SPICE servers
//! - Multi-threaded event processing
//!
//! ### WebAssembly Builds
//! - Requires WebSocket proxy (see examples/websocket-proxy.py)
//! - Single-threaded event loop
//! - Cannot create multiple TCP connections per WebSocket
//! - Some browser security restrictions apply
//!
//! ## Contributing
//!
//! Contributions are welcome! Please check the [GitHub repository](https://github.com/yourusername/spice-client)
//! for contribution guidelines.
//!
//! ## License
//!
//! This project is licensed under the MIT License - see the LICENSE file for details.
// #![warn(missing_docs)] // TODO: Add documentation for all public items
// For non-WASM builds, export the native client
pub use SpiceClient;
// For WASM builds, export the WASM-specific client
pub use SpiceClient;
// Export types for convenience
pub type Client = SpiceClient;
/// Builder for creating SPICE clients
pub use SpiceClientShared;
pub use ;
pub use *;
pub use ;
// Re-export commonly used types
pub use ;