VireoRPC Binary Framing Quickstart

VireoRPC frames WebAssembly binary streams with length-prefixed varints (0.42 ms p99 encode on 64 KB payloads; throws ERR_FRAME_CAP_104 on frame overflow).

# Install and run the 64 KB framing benchmark (expect ~0.42 ms p99)
curl -fsSL https://get.vireorpc.dev/cli | sh
vireorpc bench --target wasm32-wasi --payload-kb 64 --framing varint

Rust Host Encoder

use vireorpc::{Channel, FrameConfig, WireError};

let cfg = FrameConfig::varint().max_frame_bytes(65_536);
let mut ch = Channel::connect_wasm(instance, cfg)?;
match ch.encode_frame(&buf) {
    Ok(bytes_written) => println!("framed {} bytes", bytes_written),
    Err(WireError::ERR_FRAME_CAP_104) => ch.encode_chunked(&buf, 65_536)?,
    Err(e) => return Err(e.into()),
}

TypeScript Guest Receiver

import { decodeVarintFrame } from "@vireorpc/guest";

export function onMessage(ptr: number, len: number): void {
  const frame = decodeVarintFrame(memory.buffer, ptr, len);
  if (frame.error === "ERR_FRAME_CAP_104") {
    throw new Error("Frame exceeded 64 KB VireoRPC cap");
  }
  handlePayload(frame.bytes);
}

Default flags byte supports multi-frame continuation (bit 0) and end-of-stream (bit 1). Keep individual frames at 64 KB or smaller to avoid ERR_FRAME_CAP_104 and preserve sub-millisecond p99 encode times.