Expand description
§Monocoque
A high-performance, multi-protocol messaging runtime built on io_uring.
§Architecture
Monocoque is structured as a messaging kernel with clean layering:
monocoque-core: Lock-free allocators,io_uringproactor, SPSC queues- Protocol crates: Pure state machines (sans-IO)
monocoque: Public API surface (this crate)
§Protocols (opt-in via features)
Each protocol is gated behind a feature flag to avoid loading unused code:
zmq-ZeroMQ(ZMTP 3.x) implementation
[dependencies]
monocoque-rs = { version = "0.1", features = ["zmq"] }§Quick Start
§ZeroMQ DEALER Socket (Client)
use monocoque::zmq::prelude::*;
// Connect to a ZeroMQ peer
let mut socket = DealerSocket::connect("127.0.0.1:5555").await?;
// Send a multipart message
socket.send(vec![b"Hello".to_vec().into(), b"World".to_vec().into()]).await?;
// Receive a reply
if let Ok(Some(msg)) = socket.recv().await {
println!("Received: {:?}", msg);
}§ZeroMQ ROUTER Socket (Server)
use monocoque::zmq::prelude::*;
// Bind and accept first connection
let (listener, mut socket) = RouterSocket::bind("127.0.0.1:5555").await?;
// Echo server
while let Ok(Some(msg)) = socket.recv().await {
socket.send(msg).await?;
}§Performance
- Zero-copy: Uses
bytes::Bytesfor refcounted message buffers io_uring: Native Linux async I/O (viacompio)- Lock-free: SPSC queues, no shared mutable state in hot paths
- Sans-IO: Protocol logic is pure, testable, and runtime-agnostic
§Safety
unsafecode is isolated tomonocoque-core/src/alloc/(slab allocator)- All protocol and routing layers are 100% safe Rust
- Formal invariants documented in
docs/blueprints/06-safety-model-and-unsafe-audit.md
Structs§
- Bytes
- A cheaply cloneable and sliceable chunk of contiguous memory.
- Reconnect
State - Reconnection state tracker for managing connection attempts and backoff.
- Socket
Options - Socket configuration options.
Enums§
- Reconnect
Error - Error type for reconnection operations.
- Socket
Type ZeroMQsocket types.