Skip to content
wireframe home
Menu

Common SignalA Rust router for binary protocols

wireframe

wireframe is an experimental Rust library for building servers and clients for frame-based binary protocols. Frame the bytes, route messages by ID, and keep protocol behaviour open to inspection.

A byte stream enters FrameCodec, which cuts it into frames. An envelope carrying message ID 2 and correlation ID 7 reaches the router, which sends it through middleware to the Telemetry handler; the Login and Control handlers stay unlit. A dashed reply path labelled correlation 7 runs back to the start.
Plate 27 · Technical diagram One request’s path. Bytes become frames, a frame becomes an envelope, and its message ID selects one handler. The reply keeps the request’s correlation ID. Simplified: optional fragment reassembly and message assembly are not drawn. The handler names are illustrative.

A common foundation for unfamiliar traffic. Every protocol brings its own rules. wireframe provides the framing and routing machinery, so an application can concentrate on the messages it handles.

Release
0.4.0-alpha1
Status
Alpha, unpublished
Target
2 December 2026
Rust
1.95 or newer
Runtime
Tokio
Licence
ISC

Three steps

  1. 1 Describe the messages

    first_server.rsWorking example
    #[derive(bincode::Encode, bincode::BorrowDecode, Debug)]
    struct Ping {
        body: String,
    }
    
    #[derive(bincode::Encode, bincode::BorrowDecode, Debug, PartialEq)]
    struct Pong {
        body: String,
    }
    
    const PING: u32 = 1;
    
  2. 2 Route and answer

    first_server.rsWorking example
    fn build_app() -> wireframe::Result<WireframeApp> {
        let handler: Handler<Envelope> = Arc::new(|env: &Envelope| {
            let id = env.id();
            Box::pin(async move { println!("routed message {id}") })
        });
    
        WireframeApp::new()?.route(PING, handler)?.wrap(AnswerPings)
    }
    
  3. 3 Complexity, reduced

    A tangled wireframe cube labelled By hand, framing, parsing, dispatch, and state, leads by an arrow to three stacked layers labelled codec, routes, and middleware, under the heading With wireframe.
    Plate 28 · Technical diagram Complexity, reduced. Framing, parsing, dispatch, and state, written by hand, give way to three named layers. A comparison, not a measurement.

Both panels are cut from the getting-started program, compiled and run against wireframe 0.4.0-alpha1 built from source at commit 9408f167 on 2026-12-02. A route handler returns nothing; the program’s middleware writes the Pong.

Frame. Route. Handle.

Follow the message. A codec identifies frame boundaries. The routing layer selects a handler by message ID. Middleware wraps buffered handlers. The reply retraces the way it came, and the architecture guide explains each boundary.

Fragment reassembly is a transport step and optional. Message assembly, for protocols that spread one message across several frames, is a separate step that runs after it.

The stack, layer by layer
  1. Input

    Bytes off the socket

    A Tokio TCP stream. A server that expects a preamble reads it first, under a 10-second deadline by default; without one, the connection goes straight to the application.

  2. Framing

    Cut at the length prefix

    A FrameCodec decodes frames. The default reads a 4-byte big-endian length prefix and refuses frames over 1,024 bytes.

  3. Envelope

    Read the envelope

    The serializer decodes an Envelope: a message ID, an optional correlation ID, and the payload bytes. Trailing bytes are a decoding error.

  4. Reassembly Optional

    Fragments, rejoined

    With fragmentation enabled, fragments arrive inside envelopes and are rejoined before routing, bounded by size, by count, and by time.

  5. Deflection

    Route by message ID

    One handler per ID. An ID with no route is logged and dropped; registering an ID twice fails at setup.

  6. Modulation

    Wrap the handler

    Middleware wraps route and route_response handlers. A streaming_route handler performs its own authentication and validation.

  7. Dwell

    Handle the message

    A route handler receives the envelope and returns nothing, so the default reply echoes the payload. A route_response handler returns a reply. A streaming_route handler receives the body in chunks.

  8. Retrace

    Serialize, frame, send

    Every reply, streamed or not, keeps the request’s correlation ID and leaves through the connection’s actor: optional fragmentation, the serializer, the codec’s wrapper, the before_send hook, and the encoder.

What it carries

Any wire format, one trait

FrameCodec describes any wire format: how to cut frames, where the payload sits, and where a correlation ID lives.

  • Hotline20-byte header, big-endian lengths, a transaction ID
  • MySQL3-byte little-endian length, 1-byte sequence number
  • RESPSimple strings, integers, bulk strings, and arrays

The default frame: a 4-byte big-endian length, then the payload. The three codecs above ship as worked examples.

Answer in middleware

A Transform wraps route and route_response handlers. Setup and teardown hooks carry per-connection state.

Push and streams, wired

Priority push queues, a session registry, and streamed or multi-packet replies, driven by the connection actor every WireframeServer connection owns.

One definition, both ends

WireframeClient correlates replies, reads streams, and pools reusable sockets, each opened on first use.

Test at the frame

Feed frames one byte at a time, fragment a payload, or pace a slow reader under paused time.

Three gauges: per message, 16 KiB; per connection, 64 KiB; in flight, 64 KiB. The per-message gauge ends in a red mark, labelled over: message rejected. The other two turn yellow at 80%, labelled reads pause, and end in red, labelled over: close.
Plate 15 · Technical diagram Memory budgets. Three caps on what one connection may buffer. Past the per-message cap a message is rejected; at 80% of the smaller aggregate cap reads pause; past it, the connection closes. In 0.4.0-alpha1. Defaults for the 1,024-byte frame limit; the needles are illustrative.

Large messages, bounded

Fragmentation, message assembly, and per-connection memory budgets that count fragment and assembly bytes together, slow reads at 80%, and close the connection past the cap.

Proposed · RFC 0007

Capacity is part of the design. A message leaving a queue has not necessarily left memory. The proposed budget contract accounts for retained data and admitted work by scope. Review the proposal

Plate 29 · Civic setting Avenue fly-through. A cobalt avenue connects a city of illuminated crossings. Civic setting for the Common Signal series.
Common Signal · a story in seven worksKeeping the commonsHow one connection stays fair: a steward per street, queues at the lights, and gauges on the reservoir.

Already carrying traffic

mxd, df12’s Hotline server, depends on wireframe 0.3.0. Its transport adapter frames and routes the Hotline protocol; its domain crate never imports wireframe. Hotline’s framing ships with wireframe too, as a worked codec example.

Read about mxd
Protocol
Hotline, 1990s Mac file sharing and chat
Transport
mxd-wireframe-server, on wireframe 0.3.0
Boundary
Wireframe types stop at the transport adapter

Add it to Cargo.toml

The sample crate’s dependencies, exactly as compiled, on Rust 1.95 or newer. pool and testkit are opt-in features; metrics and the bincode serializer are on by default.

Cargo.tomlWorking example
[dependencies]
wireframe = { version = "=0.4.0-alpha1", features = ["pool", "testkit"] }
tokio = { version = "1", features = ["macros", "net", "rt-multi-thread", "sync", "test-util", "time"] }
async-trait = "0.1.89"
bincode = "2.0.1"
bytes = "1.10.1"
futures = "0.3.31"
tokio-util = { version = "0.7.16", features = ["codec", "rt"] }

What we connect, we should understand.