This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
mobilecritical PriorityID: tauri2-mobile-zero-copy-ipc-streaming

Tauri 2.0 Mobile Zero-Copy Binary IPC Streaming Standard

Enforces zero-copy raw byte transfers and IPC Channel streaming for multi-megabyte payloads across the Tauri 2.0 Rust-WebView bridge. Eliminates base64 and JSON numeric array serialization that causes catastrophic WebKit heap inflation, frame drops, and mobile OS process termination.

Prohibited Anti-Pattern: Serializing Raw Binary Chunks as Base64 or JSON Numeric Arrays Across Tauri Mobile IPC

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Mobile Zero-Copy Binary IPC Streaming Standard - Enforces zero-copy raw byte transfers and IPC Channel streaming for multi-megabyte payloads across the Tauri 2.0 Rust-WebView bridge. Eliminates base64 and JSON numeric array serialization that causes catastrophic WebKit heap inflation, frame drops, and mobile OS process termination.
globs: src/**/*.{ts,tsx}, src-tauri/src/**/*.rs
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/tauri2-mobile-zero-copy-ipc-streaming"
---

# Tauri 2.0 Mobile Zero-Copy Binary IPC Streaming Standard

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Serializing Raw Binary Chunks as Base64 or JSON Numeric Arrays Across Tauri Mobile IPC

## System Constraints
You are a Principal Engineer enforcing the Tauri 2.0 IPC Transferable Zero-Copy Buffer Streaming Protocol on mobile platforms. Mandate invariants that eliminate JSON serialization and base64 parsing overhead across the Rust-to-WebView boundary.

## Strict Guidelines
- Engineers MUST ALWAYS return `tauri::ipc::Response` containing raw binary vectors or stream via `tauri::ipc::Channel` for binary payloads exceeding 64KB.
- Engineers MUST NOT serialize `Vec<u8>` via standard Serde JSON or encode byte buffers into base64 strings when communicating with the mobile WebView.
- Frontend consumers MUST invoke binary endpoints using `{ responseType: ResponseType.Binary }` or process `Channel` payloads directly as `ArrayBuffer`/`Uint8Array`.
- Services MUST process incoming streaming chunks using direct TypedArray views (`Uint8Array.subarray()`) instead of cloning or converting chunks into intermediate DOM strings.
- Components NEVER buffer continuous binary streams entirely in JavaScript memory; streams MUST be consumed iteratively or written directly to memory-mapped sinks or WebGL/WebGPU textures.

## Bad vs Good Implementations
### Zero-Copy Binary Stream Consumer vs. JSON/Base64 Inefficient Bridge

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Transporting binary payloads via Base64 strings or default Serde JSON arrays forces WebKit to allocate millions of small object handles, expanding memory consumption by 300-400% and causing aggressive garbage collector stalls on resource-constrained mobile devices.
```typescript
import { invoke } from '@tauri-apps/api/core';

interface LegacyChunkResponse {
  data: string; // Base64-encoded binary payload
  timestamp: number;
}

// ANTI-PATTERN: Base64 decoding causes intermediate string allocations,
// 33% wire overhead, and catastrophic WebKit GC spikes on iOS/Android.
export async function fetchMobileTelemetryDump(traceId: string): Promise<Uint8Array> {
  const response = await invoke<LegacyChunkResponse>('get_telemetry_dump', { traceId });
  const binaryString = atob(response.data);
  const bytes = new Uint8Array(binaryString.length);
  for (let i = 0; i < binaryString.length; i++) {
    bytes[i] = binaryString.charCodeAt(i);
  }
  return bytes;
}
```

#### Production Standard (Correct)
> **Standard**: Leverages Tauri 2.0 Channels with native typed array transfer. Payloads are piped directly from Rust byte buffers into JavaScript TypedArrays without base64 decoding or intermediate heap allocations, avoiding mobile WebKit GC pauses.
```typescript
import { invoke, Channel } from '@tauri-apps/api/core';

// PRODUCTION INVARIANT: Use Tauri 2.0 Channels with raw Uint8Array payloads
// to stream directly from Rust to WebView memory without JSON intermediate parsing.
export async function streamMobileTelemetryDump(
  traceId: string,
  onChunk: (chunk: Uint8Array) => void
): Promise<void> {
  const channel = new Channel<Uint8Array>();
  channel.onmessage = (chunk: Uint8Array) => {
    // Direct zero-copy TypedArray view over transferred memory
    onChunk(chunk);
  };

  await invoke('stream_telemetry_dump', {
    traceId,
    onEvent: channel
  });
}
```

Recommended MCP Servers (mcp-serverlist.com)

Equip agent with system tools to verify code for this stack.

Recommended Agent Skills (askills.dev)

Ready-to-use executable skill functions tailored to this stack.

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Tauri 2.0 Mobile Zero-Copy Binary IPC Streaming Standard

Tauri 2.0 Mobile Zero-Copy Binary IPC Streaming Standard defines an industrial-grade behavioral standard for mobile engineering. Enforces zero-copy raw byte transfers and IPC Channel streaming for multi-megabyte payloads across the Tauri 2.0 Rust-WebView bridge. Eliminates base64 and JSON numeric array serialization that causes catastrophic WebKit heap inflation, frame drops, and mobile OS process termination. Modern software architectures require strict adherence to deterministic patterns to guarantee high availability, maintainability, and zero security vulnerabilities.

Framework Paradigm Shift & Drift MechanicsLLMs are trained on millions of open-source repositories containing outdated code, legacy idioms, and unpatched antipatterns. When coding assistants generate implementations for this stack, they default to common statistical tokens: Serializing Raw Binary Chunks as Base64 or JSON Numeric Arrays Across Tauri Mobile IPC Without an explicit system instruction file, developers spend hours debugging silent failures.
Failure Modes & Production Blast Radius

Hazard Analysis: What Breaks Without This Rule

The following failure modes have been cataloged from hundreds of hours of production code reviews where AI assistants produced non-compliant implementations:

Failure ModeAI Symptom (The Anti-Pattern)SeverityProduction Impact & Remedy
AI Hallucination & Deprecation DriftSerializing Raw Binary Chunks as Base64 or JSON Numeric Arrays Across Tauri Mobile IPCCritical
Violating this industrial standard introduces regression bugs, security risks, and unexpected runtime failures in production.
Enforce explicit behavioral system directives across all AI coding assistants in your repository.
Silent Architecture InconsistencyAI assistants produce mixed paradigms across files, creating fragmented codebase conventions.Medium
Increases cognitive load during code reviews and leads to maintenance debt across engineering teams.
Pin project conventions in .cursor/rules, CLAUDE.md, and AGENTS.md so all team agents follow identical guardrails.
Architectural Directives in Detail

Step-by-Step Production Directives

Each rule constraint below is injected into the AI agent's system prompt to establish deterministic boundaries:

1

Engineers MUST ALWAYS return `tauri

Engineers MUST ALWAYS return `tauri::ipc::Response` containing raw binary vectors or stream via `tauri::ipc::Channel` for binary payloads exceeding 64KB.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
2

Engineers MUST NOT serialize `Vec<u8>` via standard Serde JSON or encode byte buffers into base64 strings when communicating with the mobile WebView.

Engineers MUST NOT serialize `Vec<u8>` via standard Serde JSON or encode byte buffers into base64 strings when communicating with the mobile WebView.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
3

Frontend consumers MUST invoke binary endpoints using `{ responseType

Frontend consumers MUST invoke binary endpoints using `{ responseType: ResponseType.Binary }` or process `Channel` payloads directly as `ArrayBuffer`/`Uint8Array`.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
4

Services MUST process incoming streaming chunks using direct TypedArray views (`Uint8Array.subarray()`) instead of cloning or converting chunks into intermediate DOM strings.

Services MUST process incoming streaming chunks using direct TypedArray views (`Uint8Array.subarray()`) instead of cloning or converting chunks into intermediate DOM strings.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
5

Components NEVER buffer continuous binary streams entirely in JavaScript memory

Components NEVER buffer continuous binary streams entirely in JavaScript memory; streams MUST be consumed iteratively or written directly to memory-mapped sinks or WebGL/WebGPU textures.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
Technical Questions & Answers

Frequently Asked Technical Questions

Common questions developers face when configuring AI coding assistants for this stack:

Q:Why is Tauri 2.0 Mobile Zero-Copy Binary IPC Streaming Standard critical for AI coding assistants?

Enforces zero-copy raw byte transfers and IPC Channel streaming for multi-megabyte payloads across the Tauri 2.0 Rust-WebView bridge. Eliminates base64 and JSON numeric array serialization that causes catastrophic WebKit heap inflation, frame drops, and mobile OS process termination. Without explicit behavioral boundaries, AI coding assistants (Cursor, Claude Code, Windsurf, Codex) rely on training data averages, which frequently produce deprecated, inefficient, or vulnerable code patterns.

Q:How does adopting this rule prevent AI hallucinations?

This rule explicitly declares what the AI must avoid (Serializing Raw Binary Chunks as Base64 or JSON Numeric Arrays Across Tauri Mobile IPC) and prescribes verified positive examples. Grounding the LLM with negative and positive pairs eliminates guesswork.

Q:Which AI coding environments are supported?

This specification is multi-platform compatible: Cursor (.cursor/rules/*.mdc & .cursorrules), Anthropic Claude Code (CLAUDE.md), Windsurf (.windsurfrules), Codex / Cline (AGENTS.md), and GitHub Copilot (.github/copilot-instructions.md).

Q:Can I combine this rule with other technology stacks?

Yes. Use the Interactive Stack Builder or download an Agent Pack to merge this rule with other frontend, backend, database, security, and DevOps rules without syntax collision.

Open Specification · CC BY 4.0·Free for Personal, Team & Commercial In-Repo Use

Citation & Open Source Attribution Guidelines

This specification is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0). You are completely free to adapt and share this rule in your workspace. If citing, including in public AI benchmark datasets, or redistributing, attribution to AgentRules.org is required.

Related MOBILE Rules

View all rules →
1 Rule in Stack

Tauri