openrtc 0.2.0

OpenRTC: a Rust-first P2P runtime for device discovery, signaling, and iroh/QUIC networking.
Documentation

Pluto RTC Rust Core

The Rust crate is the realtime engine behind Pluto RTC.

It powers:

  • the native runtime used by Tauri and other native hosts
  • the WASM runtime loaded by the npm package in browsers

Core Responsibilities

  • app-scoped device discovery
  • presence publishing and cleanup
  • signaling messages and sessions
  • room membership
  • peer identity resolution
  • iroh endpoint lifecycle and connection management
  • shared runtime records used by both native and WASM hosts

Native vs WASM

Native

Used for:

  • Tauri desktop/mobile-style hosts
  • headless or CLI-style runners
  • advanced endpoint and router integration

Native-only features include:

  • endpoint adoption/export
  • custom router / no-internal-router mode
  • native auth relay helpers
  • protocol registry and plugin registration

WASM

The same runtime logic compiles to WebAssembly for browser hosts.

The npm package loads that WASM build and forwards auth/runtime configuration into it. The browser path should behave like the native path at the runtime-contract level.

Recommended Native Shape

  • use ClientBuilder / injected runtime construction
  • keep host-specific behavior outside the core where possible
  • use the runtime manager and protocol registry for advanced native composition

Peer Sessions and Custom Protocols

The Rust core owns one peer-session view per deviceId. Host layers should consume connected peer-session snapshots rather than reason about transport records directly.

Protocol authors have two supported extension paths:

  1. Session-adjacent stream composition

    • wait for a connected peer session
    • open open_bi / open_uni streams
    • define framing and message semantics externally
  2. ALPN protocol plugins

    • register protocol plugins through RuntimeManager / ProtocolRegistry
    • use SessionAdjacent plugins for runtime-ready hooks without ALPN routing
    • use Alpn plugins when the native runtime should register a dedicated ALPN

WASM/browser consumers should prefer the first model. The second is a Rust-first advanced capability.

Important Rule

Rust owns discovery, signaling, presence, lifecycle, and peer identity. TypeScript should wrap those contracts, not duplicate them.