spice-client 0.2.0

A pure Rust SPICE client library with native and WebAssembly support
# ๐Ÿš€ spice-client

[![Crates.io](https://img.shields.io/crates/v/spice-client.svg)](https://crates.io/crates/spice-client)
[![Documentation](https://docs.rs/spice-client/badge.svg)](https://docs.rs/spice-client)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](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

| Channel | Status | Description |
|---------|--------|-------------|
| 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
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

# 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**