Files
RemoteDesk/docs/adr/0001-all-rust-runtime.md
曾志威 19a8e03a83
ci / rust (push) Canceled after 0s
ci / web (push) Canceled after 0s
ci / package-preview (push) Canceled after 0s
ci / package-installer (push) Canceled after 0s
ci / linux-agent (push) Canceled after 0s
ci / edge-service (push) Canceled after 0s
ci / coturn-pop (push) Canceled after 0s
ci / package-windows-host (push) Canceled after 0s
Document all-Rust migration and extend native media stack
2026-08-14 14:31:57 +08:00

3.5 KiB

ADR 0001: All-Rust RemoteDesk Runtime

  • Status: Accepted
  • Date: 2026-08-14

Decision

RemoteDesk uses Rust for every shipped runtime component. Go and Hysteria2 are not part of the target architecture.

The product consists of a Rust Agent server, a Rust native Client, shared Rust protocol crates, and optional Rust signaling and relay services required by WebRTC.

The native Client uses winit for cross-platform windows and input events, wgpu for GPU rendering, egui for the control interface, and str0m for WebRTC and DataChannel support. Platform hardware codecs provide video decode and platform audio APIs are exposed through Rust abstractions.

The Agent uses str0m WebRTC, platform capture and input APIs, platform hardware video encoders, Opus audio, and Rust HTTPS/WebSocket signaling where required.

Transport

WebRTC is the primary real-time transport:

  • RTP/RTCP carries video and audio.
  • A reliable ordered DataChannel carries authentication-bound control, keyboard, clipboard, and session state.
  • An unordered limited-retransmission DataChannel carries pointer movement and disposable telemetry.
  • ICE/STUN provides direct connectivity and TURN provides relay fallback.

Large file transfer and software updates use a separate reliable Rust HTTPS/QUIC service so they cannot block real-time media or input.

Media and rendering

Compressed video may pass through ordinary Rust byte buffers. Decoded raw frames must remain on platform GPU surfaces and be rendered by the native client without JavaScript, WebView, Tauri IPC, or CPU bitmap transport.

Target platform paths are Windows Graphics Capture or DXGI with Media Foundation and D3D11/D3D12; Linux PipeWire, DMA-BUF, VA-API, and Vulkan; and macOS ScreenCaptureKit, VideoToolbox, and Metal.

wgpu is the cross-platform presentation abstraction. Platform-specific interop remains isolated behind Rust modules where wgpu cannot directly import a codec surface.

Removed architecture

The following are not part of the target architecture:

  • Go runtime components and the Go Hysteria2 adapter.
  • Hysteria2 as a default or optional transport.
  • Tauri, WebView, React, or JavaScript as the shipped desktop GUI.
  • Software video fallback and compatibility modes.
  • A separately shipped Edge application unrelated to the Agent/Client model.

Existing source and historical documentation may temporarily describe these components during migration. This ADR takes precedence wherever descriptions conflict.

Repository target

agent/       Rust server, capture, encode, input, audio, and WebRTC
client/      Rust native client, GUI, decode, render, input, and audio
protocol/    Shared Rust protocol and message contracts
packaging/   Windows, Linux, and macOS packages for Agent and Client
docs/        Architecture decisions and operational documentation

Consequences

  • One language, toolchain, lockfile, and security review boundary covers the shipped application.
  • The client avoids WebView frame copies and browser-process overhead.
  • WebRTC supplies NAT traversal and real-time media feedback instead of a custom QUIC media protocol.
  • str0m does not provide capture, codecs, rendering, or TURN; these remain explicit platform and deployment responsibilities.
  • Migration is complete only after Go/Hysteria2 and Tauri/Web assets are removed from builds, packages, CI, and current documentation.

The ordered implementation and acceptance plan is maintained in All-Rust Migration Plan.