# rustvnc/rustvncserver-android architecture

> Architecture diagram of the GitHub repository rustvnc/rustvncserver-android, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rustvnc/rustvncserver-android
- Repository: https://github.com/rustvnc/rustvncserver-android
- Video tour (about a minute): https://gitdiagram.com/rustvnc/rustvncserver-android/video

## Overview

This crate exposes rustvncserver to Android applications through JNI. Java configures service class names before loading the library; native registration then exposes server lifecycle and control methods, while server events are dispatched to Java callbacks. The README documents framebuffer, clipboard, repeater/reverse connections, client information, and CopyRect capabilities. These bindings share one source file; unsampled registration and event wiring are represented only where supported by the excerpts or documentation.

Main entry points: [`src/lib.rs`](https://github.com/rustvnc/rustvncserver-android/blob/main/src/lib.rs) (VNC bindings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_jni["JNI Setup"]
  node_jni_onload["JNI load<br/>[lib.rs]"]
  node_runtime_config["Runtime config<br/>[lib.rs]"]
  node_native_registration["Native registration<br/>[lib.rs]"]
end

subgraph group_server["Server Lifecycle"]
  node_vnc_bindings["VNC bindings<br/>[lib.rs]"]
  node_server_state["Server state<br/>[lib.rs]"]
  node_async_runtime["Async runtime<br/>[lib.rs]"]
  node_event_dispatch["Event dispatch<br/>[lib.rs]"]
end

subgraph group_controls["Server Controls"]
  node_framebuffer["Framebuffer controls<br/>[lib.rs]"]
  node_clipboard["Clipboard controls<br/>[lib.rs]"]
  node_connection_controls["Connection controls<br/>[lib.rs]"]
  node_copyrect["CopyRect controls<br/>[lib.rs]"]
end

node_java_app(("Android Java app"))
node_main_service["MainService"]
node_input_service["InputService"]
node_rustvncserver["rustvncserver"]
node_vnc_clients(("VNC clients"))

node_java_app -->|"loads library"| node_jni_onload
node_java_app -->|"sets properties"| node_runtime_config
node_jni_onload -->|"registers natives"| node_native_registration
node_runtime_config -->|"configures classes"| node_native_registration
node_native_registration -->|"registers methods"| node_main_service
node_native_registration -->|"registers methods"| node_input_service
node_main_service -->|"invokes natives"| node_vnc_bindings
node_input_service -->|"invokes natives"| node_vnc_bindings
node_vnc_bindings -->|"manages"| node_server_state
node_vnc_bindings -->|"runs async work"| node_async_runtime
node_vnc_bindings -->|"starts and controls"| node_rustvncserver
node_server_state -->|"holds server"| node_rustvncserver
node_rustvncserver -->|"emits events"| node_event_dispatch
node_event_dispatch -->|"calls callbacks"| node_main_service
node_event_dispatch -->|"calls callbacks"| node_input_service
node_vnc_bindings -->|"exposes updates"| node_framebuffer
node_framebuffer -->|"updates or resizes"| node_rustvncserver
node_vnc_bindings -->|"exposes transfer"| node_clipboard
node_clipboard -->|"sends text"| node_rustvncserver
node_vnc_bindings -->|"exposes connections"| node_connection_controls
node_connection_controls -->|"manages clients"| node_rustvncserver
node_vnc_bindings -->|"exposes operations"| node_copyrect
node_copyrect -->|"performs copy"| node_rustvncserver
node_vnc_clients -->|"connect"| node_rustvncserver

click node_jni_onload "https://github.com/rustvnc/rustvncserver-android/blob/main/src/lib.rs"
click node_runtime_config "https://github.com/rustvnc/rustvncserver-android/blob/main/src/lib.rs"
click node_native_registration "https://github.com/rustvnc/rustvncserver-android/blob/main/src/lib.rs"
click node_vnc_bindings "https://github.com/rustvnc/rustvncserver-android/blob/main/src/lib.rs"
click node_server_state "https://github.com/rustvnc/rustvncserver-android/blob/main/src/lib.rs"
click node_async_runtime "https://github.com/rustvnc/rustvncserver-android/blob/main/src/lib.rs"
click node_event_dispatch "https://github.com/rustvnc/rustvncserver-android/blob/main/src/lib.rs"
click node_framebuffer "https://github.com/rustvnc/rustvncserver-android/blob/main/src/lib.rs"
click node_clipboard "https://github.com/rustvnc/rustvncserver-android/blob/main/src/lib.rs"
click node_connection_controls "https://github.com/rustvnc/rustvncserver-android/blob/main/src/lib.rs"
click node_copyrect "https://github.com/rustvnc/rustvncserver-android/blob/main/src/lib.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_jni_onload,node_runtime_config,node_native_registration,node_vnc_clients toneBlue
class node_vnc_bindings,node_server_state,node_async_runtime,node_event_dispatch toneAmber
class node_framebuffer,node_clipboard,node_connection_controls,node_copyrect,node_rustvncserver toneMint
class node_java_app,node_main_service,node_input_service toneIndigo
```

## Components

### JNI Setup

- [JNI load](https://github.com/rustvnc/rustvncserver-android/blob/main/src/lib.rs): `src/lib.rs`
- [Runtime config](https://github.com/rustvnc/rustvncserver-android/blob/main/src/lib.rs): `src/lib.rs`
- [Native registration](https://github.com/rustvnc/rustvncserver-android/blob/main/src/lib.rs): `src/lib.rs`

### Server Lifecycle

- [VNC bindings](https://github.com/rustvnc/rustvncserver-android/blob/main/src/lib.rs): `src/lib.rs`
- [Server state](https://github.com/rustvnc/rustvncserver-android/blob/main/src/lib.rs): `src/lib.rs`
- [Async runtime](https://github.com/rustvnc/rustvncserver-android/blob/main/src/lib.rs): `src/lib.rs`
- [Event dispatch](https://github.com/rustvnc/rustvncserver-android/blob/main/src/lib.rs): `src/lib.rs`

### Server Controls

- [Framebuffer controls](https://github.com/rustvnc/rustvncserver-android/blob/main/src/lib.rs): `src/lib.rs`
- [Clipboard controls](https://github.com/rustvnc/rustvncserver-android/blob/main/src/lib.rs): `src/lib.rs`
- [Connection controls](https://github.com/rustvnc/rustvncserver-android/blob/main/src/lib.rs): `src/lib.rs`
- [CopyRect controls](https://github.com/rustvnc/rustvncserver-android/blob/main/src/lib.rs): `src/lib.rs`

### Other components

- **Android Java app**
- **MainService**
- **InputService**
- **rustvncserver**
- **VNC clients**

## Connections

- Android Java app → JNI load: loads library
- Android Java app → Runtime config: sets properties
- JNI load → Native registration: registers natives
- Runtime config → Native registration: configures classes
- Native registration → MainService: registers methods
- Native registration → InputService: registers methods
- MainService → VNC bindings: invokes natives
- InputService → VNC bindings: invokes natives
- VNC bindings → Server state: manages
- VNC bindings → Async runtime: runs async work
- VNC bindings → rustvncserver: starts and controls
- Server state → rustvncserver: holds server
- rustvncserver → Event dispatch: emits events
- Event dispatch → MainService: calls callbacks
- Event dispatch → InputService: calls callbacks
- VNC bindings → Framebuffer controls: exposes updates
- Framebuffer controls → rustvncserver: updates or resizes
- VNC bindings → Clipboard controls: exposes transfer
- Clipboard controls → rustvncserver: sends text
- VNC bindings → Connection controls: exposes connections
- Connection controls → rustvncserver: manages clients
- VNC bindings → CopyRect controls: exposes operations
- CopyRect controls → rustvncserver: performs copy
- VNC clients → rustvncserver: connect
