This documentation is part of the "Projects with Books" initiative at zenOSmosis.
The source code for this project is available on GitHub.
Workspace Structure
Loading…
Workspace Structure
Relevant source files
Purpose and Scope
This document details the Cargo workspace organization of the rust-muxio repository. It catalogs all workspace member crates, their locations in the directory tree, their roles within the overall system architecture, and their dependency relationships. For information about the design philosophy and layered architecture principles, see Design Philosophy and Layered Architecture.
Workspace Overview
The rust-muxio repository is organized as a Cargo workspace containing 11 member crates. The workspace is configured with resolver version 2 and defines shared metadata (version, authors, license, repository) inherited by all member crates.
Sources:
graph TB
subgraph "Root Directory"
ROOT["muxio (Root Crate)"]
end
subgraph "extensions/"
EXT_TEST["muxio-ext-test"]
RPC_SERVICE["muxio-rpc-service"]
RPC_CALLER["muxio-rpc-service-caller"]
RPC_ENDPOINT["muxio-rpc-service-endpoint"]
TOKIO_SERVER["muxio-tokio-rpc-server"]
TOKIO_CLIENT["muxio-tokio-rpc-client"]
WASM_CLIENT["muxio-wasm-rpc-client"]
end
subgraph "examples/"
EXAMPLE_APP["example-muxio-ws-rpc-app"]
EXAMPLE_DEF["example-muxio-rpc-service-definition"]
end
ROOT -->|extends| RPC_SERVICE
RPC_SERVICE -->|extends| RPC_CALLER
RPC_SERVICE -->|extends| RPC_ENDPOINT
RPC_CALLER -->|implements| TOKIO_CLIENT
RPC_CALLER -->|implements| WASM_CLIENT
RPC_ENDPOINT -->|implements| TOKIO_SERVER
EXAMPLE_DEF -->|uses| RPC_SERVICE
EXAMPLE_APP -->|demonstrates| EXAMPLE_DEF
Workspace Member Listing
The workspace members are declared in the root Cargo.toml and organized into three categories:
| Crate Name | Directory Path | Category | Primary Purpose |
|---|---|---|---|
muxio | . | Core | Binary framing protocol and stream multiplexing |
muxio-rpc-service | extensions/muxio-rpc-service | RPC Framework | Service trait definitions and method ID generation |
muxio-rpc-service-caller | extensions/muxio-rpc-service-caller | RPC Framework | Client-side RPC invocation interface |
muxio-rpc-service-endpoint | extensions/muxio-rpc-service-endpoint | RPC Framework | Server-side handler registration and dispatch |
muxio-tokio-rpc-server | extensions/muxio-tokio-rpc-server | Platform Extension | Tokio-based WebSocket RPC server |
muxio-tokio-rpc-client | extensions/muxio-tokio-rpc-client | Platform Extension | Tokio-based WebSocket RPC client |
muxio-wasm-rpc-client | extensions/muxio-wasm-rpc-client | Platform Extension | WASM browser-based RPC client |
muxio-ext-test | extensions/muxio-ext-test | Testing | Integration test suite |
example-muxio-rpc-service-definition | examples/example-muxio-rpc-service-definition | Example | Shared service definition for examples |
example-muxio-ws-rpc-app | examples/example-muxio-ws-rpc-app | Example | Demonstration application |
Sources:
Core Library: muxio
The root crate muxio (located at repository root .) provides the foundational binary framing protocol and stream multiplexing primitives. This crate is runtime-agnostic and has minimal dependencies.
Key Components:
RpcDispatcher- Request correlation and response routingRpcSession- Stream multiplexing and per-stream decodersRpcStreamEncoder/RpcStreamDecoder- Frame encoding/decodingRpcRequest/RpcResponse/RpcHeader- Core message types
Direct Dependencies:
bitcode- Binary serializationchrono- Timestamp generationonce_cell- Lazy static initializationtracing- Structured logging
Dev Dependencies:
rand- Random data generation for teststokio- Async runtime for tests
Sources:
RPC Framework Extensions
muxio-rpc-service
Located at extensions/muxio-rpc-service, this crate provides trait definitions for RPC services and compile-time method ID generation.
Key Exports:
RpcMethodPrebufferedtrait - Defines prebuffered RPC method signaturesDynamicChannelReceiver/DynamicChannelSender- Channel abstractions for streaming- Method ID constants via
xxhash-rust
Dependencies:
muxio- Core framing and session managementbitcode- Parameter/response serializationxxhash-rust- Compile-time method ID generationnum_enum- Message type discriminationasync-trait- Async trait supportfutures- Channel and stream utilities
Sources:
muxio-rpc-service-caller
Located at extensions/muxio-rpc-service-caller, this crate defines the RpcServiceCallerInterface trait for platform-agnostic client-side RPC invocation.
Key Exports:
RpcServiceCallerInterfacetrait - Abstract client interface- Helper functions for invoking prebuffered and streaming methods
Dependencies:
muxio- Core session and dispatchermuxio-rpc-service- Service definitionsasync-trait- Trait async supportfutures- Future combinatorstracing- Instrumentation
Sources:
muxio-rpc-service-endpoint
Located at extensions/muxio-rpc-service-endpoint, this crate defines the RpcServiceEndpointInterface trait for platform-agnostic server-side handler registration and request processing.
Key Exports:
RpcServiceEndpointInterfacetrait - Abstract server interface- Handler registration and dispatch utilities
Dependencies:
muxio- Core dispatcher and sessionmuxio-rpc-service- Service trait definitionsmuxio-rpc-service-caller- For bidirectional RPC (server-to-client calls)bitcode- Request/response deserializationasync-trait- Trait async supportfutures- Channel management
Sources:
Platform-Specific Extensions
muxio-tokio-rpc-server
Located at extensions/muxio-tokio-rpc-server, this crate provides a Tokio-based WebSocket RPC server implementation using Axum and tokio-tungstenite.
Key Exports:
RpcServerstruct - Main server implementation- Axum WebSocket handler integration
- Connection lifecycle management
Dependencies:
muxio- Core session primitivesmuxio-rpc-service- Service definitionsmuxio-rpc-service-caller- For bidirectional communicationmuxio-rpc-service-endpoint- Server endpoint interfaceaxum- HTTP/WebSocket frameworktokio- Async runtimetokio-tungstenite- WebSocket transportbytes- Byte buffer utilitiesfutures-util- Stream combinatorsasync-trait- Async trait implementations
Sources:
muxio-tokio-rpc-client
Located at extensions/muxio-tokio-rpc-client, this crate provides a Tokio-based WebSocket RPC client with Arc-based lifecycle management and background task coordination.
Key Exports:
RpcClientstruct - Main client implementation- Connection state tracking with
RpcClientConnectionState - Arc-based shared ownership model
Dependencies:
muxio- Core dispatcher and sessionmuxio-rpc-service- Service definitionsmuxio-rpc-service-caller- Client interface implementationmuxio-rpc-service-endpoint- For bidirectional communicationaxum- (Used for shared types)tokio- Async runtimetokio-tungstenite- WebSocket transportbytes- Byte buffer utilitiesfutures/futures-util- Async combinatorsasync-trait- Trait async support
Sources:
muxio-wasm-rpc-client
Located at extensions/muxio-wasm-rpc-client, this crate provides a WASM-compatible RPC client for browser environments using wasm-bindgen and JavaScript interop.
Key Exports:
RpcWasmClientstruct - WASM client implementationMUXIO_STATIC_RPC_CLIENT_REF- Thread-local static client reference- JavaScript bridge functions (
static_muxio_write_bytes, etc.)
Dependencies:
muxio- Core framing and sessionmuxio-rpc-service- Service definitionsmuxio-rpc-service-caller- Client interfacemuxio-rpc-service-endpoint- For bidirectional communicationwasm-bindgen- JavaScript FFIjs-sys- JavaScript API bindingswasm-bindgen-futures- Async/await in WASMfutures/futures-util- Future utilitiesasync-trait- Trait support
Sources:
Testing Infrastructure
muxio-ext-test
Located at extensions/muxio-ext-test, this integration test crate validates end-to-end functionality across client and server implementations.
Test Coverage:
- Native client to native server communication
- Service definition validation
- Error handling and edge cases
Dependencies:
muxio-rpc-service- Service trait testingmuxio-rpc-service-caller- Client interface testingmuxio-rpc-service-endpoint- Server endpoint testingmuxio-tokio-rpc-client- Client implementation testingmuxio-tokio-rpc-server- Server implementation testingexample-muxio-rpc-service-definition- Test service definitionstokio- Async test runtimetracing/tracing-subscriber- Test instrumentationbytemuck- Binary data utilities
Sources:
Example Applications
example-muxio-rpc-service-definition
Located at examples/example-muxio-rpc-service-definition, this crate defines shared RPC service contracts used across example applications.
Service Definitions:
- Basic arithmetic operations (Add, Multiply)
- Echo service
- Demonstrates
RpcMethodPrebufferedtrait implementation
Dependencies:
muxio-rpc-service- Service trait definitionsbitcode- Serialization for parameters and responses
Sources:
example-muxio-ws-rpc-app
Located at examples/example-muxio-ws-rpc-app, this demonstration application shows complete client-server setup with WebSocket transport.
Demonstrates:
- Server instantiation with
RpcServer - Client connection with
RpcClient - Service handler registration
- RPC method invocation
- Benchmarking with criterion
Dependencies:
example-muxio-rpc-service-definition- Shared service contractsmuxio- Core primitivesmuxio-rpc-service-caller- Client callingmuxio-tokio-rpc-client- Client implementationmuxio-tokio-rpc-server- Server implementationtokio- Async runtimeasync-trait- Handler trait implementationcriterion- Performance benchmarkingfutures- Async utilitiestracing/tracing-subscriber- Application loggingdoc-comment- Documentation tests
Sources:
Workspace Dependency Graph
Sources:
Directory Structure to Code Entity Mapping
Sources:
Shared Workspace Configuration
All workspace member crates inherit common metadata from the workspace-level configuration:
| Property | Value | Purpose |
|---|---|---|
version | 0.10.0-alpha | Synchronized versioning across all crates |
edition | 2024 | Rust edition (preview edition) |
authors | Jeremy Harris | Package authorship |
repository | https://github.com/jzombie/rust-muxio | Source location |
license | Apache-2.0 | Licensing terms |
publish | true | crates.io publication enabled |
resolver | 2 | Cargo feature resolver version |
Workspace-wide Third-Party Dependencies:
The workspace defines shared third-party dependency versions to ensure consistency:
| Dependency | Version | Used By |
|---|---|---|
async-trait | 0.1.88 | RPC service traits |
axum | 0.8.4 | Server framework |
bitcode | 0.6.6 | Serialization |
tokio | 1.45.1 | Async runtime |
tokio-tungstenite | 0.26.2 | WebSocket transport |
tracing | 0.1.41 | Logging infrastructure |
tracing-subscriber | 0.3.20 | Log output formatting |
xxhash-rust | 0.8.15 | Method ID hashing |
num_enum | 0.7.3 | Enum discriminants |
futures | 0.3.31 | Async utilities |
Sources:
Crate Size and Complexity Metrics
Based on Cargo.lock dependency counts:
| Crate | Direct Dependencies | Purpose Complexity |
|---|---|---|
muxio | 5 | Low - Core primitives only |
muxio-rpc-service | 6 | Medium - Trait definitions and hashing |
muxio-rpc-service-caller | 5 | Low - Interface abstraction |
muxio-rpc-service-endpoint | 6 | Low - Interface abstraction |
muxio-tokio-rpc-server | 10 | High - Full server stack |
muxio-tokio-rpc-client | 11 | High - Full client stack |
muxio-wasm-rpc-client | 11 | High - WASM bridge complexity |
muxio-ext-test | 8 | Medium - Integration testing |
example-muxio-rpc-service-definition | 2 | Low - Simple definitions |
example-muxio-ws-rpc-app | 9 | Medium - Demonstration code |
Sources: