Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

GitHub

This documentation is part of the "Projects with Books" initiative at zenOSmosis.

The source code for this project is available on GitHub.

Muxio Overview

Loading…

Muxio Overview

Relevant source files

Muxio is a high-performance, transport-agnostic framework designed for layered stream multiplexing and schemaless RPC communication in Rust Cargo.toml:3-4 It provides a modular toolkit that separates low-level binary framing from high-level service logic, allowing developers to build bidirectional, efficient communication protocols that run seamlessly across native and WASM environments README.md:20-27

System Architecture: From Bytes to Services

The Muxio ecosystem is organized into a hierarchy of layers. At the bottom is a compact binary framing protocol; in the middle is an RPC multiplexing engine; and at the top are specialized transport implementations for Tokio, IPC, and WASM README.md:22-27 README.md:50-55

Conceptual Layering and Code Entities

The following diagram illustrates how the natural language concepts of the “Muxio Stack” map to specific code entities and crates within the workspace.

Muxio Layer Mapping

graph TD
    subgraph "Service_Layer_[High-Level]"
        A["RpcMethodPrebuffered"] -- "defines" --> B["example-muxio-rpc-service-definition"]
C["RpcServiceCallerInterface"] -- "implemented_by" --> D["RpcClient / RpcWasmClient"]
E["RpcServiceEndpointInterface"] -- "implemented_by" --> F["RpcServer / RpcServiceEndpoint"]
end

    subgraph "Core_Layer_[Multiplexing]"
        G["RpcSession"] -- "manages" --> H["RpcDispatcher"]
H -- "fragments_into" --> I["Frame"]
I -- "contains" --> J["FrameKind"]
end

    subgraph "Transport_Layer_[I/O]"
        K["muxio-tokio-rpc-server"] -- "provides" --> L["RpcServer"]
M["muxio-tokio-rpc-client"] -- "provides" --> N["RpcClient"]
O["muxio-wasm-rpc-client"] -- "provides" --> P["RpcWasmClient"]
Q["muxio-tokio-rpc-ipc-server"] -- "provides" --> R["IpcServer"]
end

 
   B -.-> H
 
   D -.-> H
 
   F -.-> H
 
   L -.-> G
 
   N -.-> G
 
   P -.-> G
 
   R -.-> G

Sources: Cargo.toml:16-32 README.md:22-27 README.md:50-55 DRAFT.md:43-48


Workspace Structure

Muxio uses a Cargo workspace to manage its core library and various extension crates. This structure ensures that the core remains lightweight and runtime-agnostic, while providing “batteries-included” support for common runtimes via extensions Cargo.toml:16-32

CategoryCrate NamePurpose
Coremuxio / muxio-coreFoundational binary framing and RPC dispatching logic Cargo.toml:3-4 Cargo.toml19
Service Abstractionmuxio-rpc-serviceShared traits and macros like rpc_method_id! for defining RPC contracts Cargo.toml23 README.md40
Interfacesmuxio-rpc-service-caller, muxio-rpc-service-endpointTraits for making calls and handling requests Cargo.toml:24-25
Transportsmuxio-tokio-rpc-*, muxio-wasm-rpc-clientRuntime-specific implementations for Tokio (WS/IPC) and WASM Cargo.toml:27-31
Examplesexample-muxio-ws-rpc-appDemonstrates end-to-end integration Cargo.toml21

For a detailed breakdown of the folder structure and how to build the project, see Getting Started & Workspace Layout.

Sources: Cargo.toml:16-32 README.md:50-55


Design Philosophy

Muxio is built around a “Binary-First” and “Symmetric” philosophy. Unlike many RPC frameworks that assume a Client-to-Server request-response model, Muxio treats both ends of a connection as equal peers capable of initiating and receiving multiplexed streams DRAFT.md:9-25

Key Principles

  • Runtime Agnostic : The core library uses a callback-driven model rather than forcing a specific async runtime DRAFT.md:43-48
  • Binary Efficiency : Compact binary framing protocol with only 17 bytes of header overhead per frame README.md44
  • WASM Compatibility : Designed to bridge Rust logic with JavaScript environments via a byte-passing bridge README.md53 README.md62
  • Compile-Time Method IDs : Uses xxHash3 at compile time via rpc_method_id! to avoid runtime string hashing or magic numbers README.md40

For a deep dive into the architectural principles and the “Layered Transport Kit” concept, see Design Goals & Architecture Principles.

Sources: README.md:31-48 DRAFT.md:9-25 DRAFT.md:43-48


Core Multiplexing Flow

The framework operates by interleaving Frame entities over a single transport. The RpcDispatcher coordinates these frames, ensuring that multiple concurrent requests (identified by unique Stream IDs) do not block one another README.md32 README.md44

Data Flow: From Application to Wire

Sources: README.md:32-48 DRAFT.md:43-48 Cargo.toml:58-65

Next Steps

To explore specific areas of the Muxio framework, refer to the following child pages: