rfb-encodings
RFB (Remote Framebuffer) protocol encoding implementations for VNC.
Support this project:
Bitcoin (BTC)
3QVD3H1ryqyxhuf8hNTTuBXSbczNuAKaM8
Ethereum (ETH)
0xaFE28A1Dd57660610Ef46C05EfAA363356e98DC7
Solana (SOL)
6uWx4wuHERBpNxyWjeQKrMLBVte91aBzkHaJb8rhw4rn
Monero (XMR)
8C5aCs7Api3WE67GMw54AhQKnJsCg6CVffCuPxUcaKoiMrnaicyvDch8M2CXTm1DJqhpHKxtLvum9Thw4yHn8zeu7sj8qmC
This crate provides encoding implementations for the VNC/RFB protocol, including all standard encodings defined in RFC 6143. It can be used to build VNC servers, clients, proxies, or recorders.
Supported Encodings
| Encoding | ID | Description | Wire Format Match | Testing Status |
|---|---|---|---|---|
| Raw | 0 | Uncompressed pixels | ✅ 100% | ✅ Tested |
| RRE | 2 | Rise-and-Run-length | ✅ 100% | ✅ Tested |
| CoRRE | 4 | Compact RRE | ✅ 100% | ⚠️ Untested* |
| Hextile | 5 | 16x16 tile-based | ✅ 100% | ✅ Tested |
| Zlib | 6 | Zlib-compressed raw | ✅ 100% | ✅ Tested |
| Tight | 7 | Multi-mode compression | ✅ 100% (all 5 modes) | ✅ Tested |
| ZlibHex | 8 | Zlib-compressed Hextile | ✅ 100% | ⚠️ Untested* |
| ZRLE | 16 | Zlib Run-Length | ✅ 100% | ✅ Tested |
| ZYWRLE | 17 | Wavelet compression | ✅ 100% | ⚠️ Untested* |
| TightPng | -260 | PNG-compressed Tight | ✅ 100% | ✅ Tested |
*Untested encodings: ZlibHex, CoRRE, and ZYWRLE are fully implemented and RFC 6143 compliant but cannot be tested with noVNC (most common VNC client) because noVNC doesn't support them. All three have been code-reviewed and verified against the RFC 6143 specification. Use the widely-supported alternatives: Zlib (instead of ZlibHex), Hextile (instead of CoRRE), and ZRLE (instead of ZYWRLE).
Features
- Pure Rust - Memory-safe implementation with no unsafe code
- RFC 6143 Compliant - Follows the official RFB protocol specification
- Persistent Streams - Maintains zlib compression state for better compression ratios
- Pixel Format Translation - Supports all VNC pixel formats (8/16/24/32-bit)
- Optional TurboJPEG - Hardware-accelerated JPEG compression via feature flag
Usage
Add this to your Cargo.toml:
[]
= "0.1"
Basic Example
use ;
// Create encoder
let encoder = TightEncoding;
// Encode RGBA pixel data
let rgba_data: = vec!;
let width = 1920;
let height = 1080;
let quality = 9; // 0-9, higher is better quality
let compression = 6; // 0-9, higher is more compression
let encoded = encoder.encode;
Advanced Usage with Persistent Streams
For better compression with Tight encoding:
use ;
let mut compressor = new;
let client_format = rgba32;
let rectangles = encode_tight_rects;
// Returns Vec<(x, y, width, height, encoded_data)>
for in rectangles
Features
turbojpeg- Enable TurboJPEG for hardware-accelerated JPEG compression in Tight encodingdebug-logging- Enable verbose debug logging for troubleshooting
Enable features in your Cargo.toml:
[]
= { = "0.1", = ["turbojpeg", "debug-logging"] }
TurboJPEG Installation
The turbojpeg feature requires libjpeg-turbo to be installed on your system:
Ubuntu/Debian:
macOS:
Windows: Download from libjpeg-turbo.org
Architecture
This crate is designed to be reusable across different VNC implementations:
encodingmodules - Individual encoder implementationsPixelFormat- VNC pixel format definition and utilitiestranslate- Pixel format translation between different color depthsTightStreamCompressortrait - Interface for persistent zlib streams
Third-Party Dependencies
Optional: libjpeg-turbo (TurboJPEG)
When using the turbojpeg feature, this crate provides FFI bindings to libjpeg-turbo, which must be installed separately on your system. libjpeg-turbo is licensed under a BSD-style license (BSD-3-Clause, IJG, and zlib components).
License Information:
- libjpeg-turbo: BSD-3-Clause, IJG License, zlib License
- Note: You are responsible for ensuring compliance with libjpeg-turbo's license terms when using the
turbojpegfeature.
License
This crate is licensed under the Apache License, Version 2.0. See LICENSE for details.
The turbojpeg feature provides optional bindings to libjpeg-turbo, which is licensed separately. See above for details.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.