📡 Wireframe
Route binary protocols in Rust, without writing the plumbing twice.
Wireframe is a Tokio library for building servers and clients that speak custom binary protocols. You describe your messages, routes, and framing; it handles connections, length limits, reassembly, correlation, and shutdown.
Website: https://df12.studio/wireframe
Why Wireframe?
Handwritten protocol servers tend to grow the same tangle of frame parsing, dispatch tables, and half-finished limits. Wireframe gives each concern one home:
- Routing by message ID: Map an identifier to a handler, and let middleware shape requests and replies around it.
- Your wire format, not ours: Use the default length-delimited framing, or
describe an existing protocol once with a
FrameCodec. - One definition for both ends: The client shares the server's codec, serializer, and envelope, so the two cannot quietly disagree.
- Limits by default: Frame sizes, decode budgets, preamble deadlines, and per-connection memory budgets are on before you configure anything.
- Tests at the frame: Feed your application partial frames, one byte at a time, without opening a socket.
Quick start
You will need Rust 1.95 or newer. The program below starts a server on a free local port, sends it a message from a client, and prints the reply. It takes about two minutes, most of which is the first compile.
Installation
Create a project and add the dependencies:
Once the alpha is available on crates.io, add these lines to Cargo.toml. Pin
the exact version during the alpha because interfaces may change from one alpha
to the next. To run this quick start before publication, run make test-doc at
the root of the alpha source checkout.
[]
= "=0.4.0-alpha1"
= { = "1", = ["macros", "rt-multi-thread"] }
= "2"
= "0.1"
Your first server and client
Replace src/main.rs with this program:
use ;
use async_trait;
use ;
// A message ID selects the route; it travels beside the payload, not inside it.
const GREET: u32 = 1;
// Handlers observe a request; middleware like this writes the reply.
;
async
Run it:
You should see Hello, Wireframe!. The
users' guide walks through this program
a step at a time, including why the reply lives in middleware.
Features
Wireframe v0.4.0-alpha1 provides:
- routing by message ID, with custom envelopes through the
Packettrait and correlation identifiers; - middleware through
Transform, and per-connection setup and teardown hooks; - replies of one frame, several, or a stream, written under back-pressure;
- server pushes with priorities, rate limits, dead-letter queues, and a registry of live connections;
- length-delimited framing by default, with worked
FrameCodecimplementations for Hotline, MySQL, and RESP inexamples/; - bincode serialization by default, a pluggable
Serializertrait, and an optional Serde bridge; - connection preambles, with a 10-second default deadline on the server;
- recovery policies for undecodable frames, and protocol hooks for setup, every outbound frame, completed replies, and truncated input;
- transport fragmentation, protocol message assembly, and per-connection memory budgets with read pacing;
- a server with configurable workers, readiness signals, graceful shutdown, and accept backoff, which keeps a panicking connection away from the others;
- a client with correlated calls, request and lifecycle hooks, tracing, streamed replies, outbound streaming sends, and optional connection pools;
metricscounters,tracingandlogevents, and test drivers behind thetestkitfeature and in thewireframe_testingcrate.
Release and development status
Wireframe v0.4.0-alpha1 is an alpha for early adopters: expect interfaces to change before 1.0, and pin the version. Upgrading from v0.3.0? The migration guide lists every change to act on.
A few things are worth knowing before you build on it:
- Request streaming is opt-in. Ordinary routes receive buffered messages. Use a streaming route to handle a body chunk by chunk.
- One request at a time per connection. Other requests wait behind a live body or a streamed reply. Server pushes can interleave with streamed replies.
- There is no built-in TLS. Terminate it in front of the server.
- Idle connections stay open while the server runs.
read_timeout_msis a housekeeping interval, so bound quiet peers in your protocol. On shutdown, the listener closes when the last accept loop exits. In-flight connection tasks may still be draining.
Examples
The examples/ directory holds complete programs. To run them, clone the
repository and start the echo server:
Then, in a second terminal in the same directory, log in against it:
The other programs run the same way:
ping_pong: typed requests and replies through middleware, explained in its walkthrough.packet_enum: telling packet types apart with a bincode enum.metadata_routing: routing from frame metadata without decoding the payload.hotline_codec,mysql_codec,resp_codec: custom framing for real protocols.async_stream,multi_packet: building responses with the streaming types, explained in the stream and channel walkthroughs.
Learn more
- Users' guide: from a first server to production and custom protocols.
- Migration guide: moving from v0.3.0.
- API reference: every public type, on docs.rs.
- Design document: architecture and rationale.
- Developers' guide: development workflow and quality gates.
- Roadmap: completed foundations and planned work.
Licence
ISC — see LICENSE for details.
Contributing
Contributions are welcome. Start with the developers' guide; automated contributors should also follow AGENTS.md.