# ๐ spice-client
[](https://crates.io/crates/spice-client)
[](https://docs.rs/spice-client)
[](https://www.gnu.org/licenses/gpl-3.0)
A modern SPICE (Simple Protocol for Independent Computing Environments) client implementation in pure Rust with WebAssembly support.
> โ ๏ธ **Experimental**: This library is under active development and APIs are subject to change. We're working on stabilizing the interface and will have a detailed roadmap available soon.
## โจ Features
- **Pure Rust** - No C dependencies, memory safe implementation
- **Cross-platform** - Native support for Linux, macOS, Windows*, and WebAssembly
- **Async/Await** - Modern async API using Tokio
- **WebAssembly Ready** - Run SPICE clients directly in web browsers
- **Multiple Channels** - Display, input, cursor, and main channel support
*\* Windows support is included but currently untested. Contributions welcome!*
## ๐๏ธ Architecture
**Modern Design with Platform Flexibility**
```
๐ฅ๏ธ Native App ๐ Web Browser
โ โ
โโโโโโผโโโโโ โโโโโโผโโโโโ
โ Tokio โ โ WASM โ
โ TCP โ โWebSocketโ
โโโโโโฌโโโโโ โโโโโโฌโโโโโ
โ โ
โโโโโโโโโโฌโโโโโโโโโโโโโโโโ
โ
โโโโโโโผโโโโโโ
โ SPICE โ
โ Server โ
โโโโโโโโโโโโโ
```
## ๐ Getting Started
### Prerequisites
- ๐ฆ Rust 1.75+
- ๐ฅ๏ธ SPICE-enabled VM (QEMU/libvirt)
### Installation
Add to your `Cargo.toml`:
```toml
[dependencies]
spice-client = "0.1.0"
```
### Quick Example
```rust
use spice_client::{SpiceClient, SpiceError};
#[tokio::main]
async fn main() -> Result<(), SpiceError> {
// Connect to SPICE server
let mut client = SpiceClient::new("localhost".to_string(), 5900);
client.connect().await?;
// Start event processing
client.start_event_loop().await?;
Ok(())
}
```
## ๐ฆ Supported Channels
| Main | โ
| Connection setup and control |
| Display | โ
| Screen rendering and updates |
| Inputs | โ
| Keyboard and mouse input |
| Cursor | โ
| Hardware cursor support |
| Audio | ๐ง | Coming soon |
| USB | ๐ง | Planned |
## ๐ ๏ธ Building
### Native Build
```bash
# Standard build
cargo build --release
# Run tests
cargo test
```
### WebAssembly Build
```bash
# Install wasm-pack
# Build for web
wasm-pack build --target web
```
## ๐ WebSocket Proxy
For browser deployments, a WebSocket-to-TCP proxy is required:
```bash
# Example proxy setup
python examples/websocket-proxy.py --spice-host localhost --spice-port 5900
```
## ๐ Current Status
This is an experimental implementation focusing on core functionality:
**Working**:
- Basic SPICE protocol handshake
- Display channel with drawing operations
- Keyboard and mouse input
- Cursor updates
- WebAssembly compilation
**In Progress**:
- Audio channels
- Clipboard integration
- Performance optimizations
- Comprehensive testing
**Planned**:
- USB redirection
- File transfer
- Enhanced compression (LZ4)
- TLS encryption
## ๐ค Contributing
We welcome contributions! Please:
- ๐ Report bugs via GitHub issues
- ๐ก Discuss major changes before implementing
- ๐งช Add tests for new functionality
- ๐ Update documentation as needed
## ๐ License
GPL v3 License ๐
---
**Part of the โก Quickemu Manager project**