tarpc-cat
RPC framework built on comp-cat-rs: typed effects, no async, categorical foundations.
Reimagines the core abstractions of tarpc using Io<E, A> as the effect type, blocking I/O via Io::suspend, and thread-based concurrency. Nothing executes until .run().
Features
- Lazy effects -- all operations return
Io<Error, A>, composable viamap,flat_map,zip - Linear state-threading transport -- the
Transporttrait consumes and returns itself on each operation, avoiding shared state - Connection-per-request client -- simple, stateless TCP calls
- Thread-per-connection server -- accepts connections via iterator combinators, spawns a thread for each
- Pluggable transport --
TcpTransportfor production,ChannelTransportfor testing - Length-delimited JSON wire format -- 4-byte big-endian length prefix + JSON payload
- No async, no tokio -- pure
std::net+comp-cat-rseffects
Usage
Define a service
use Serve;
use Error;
use Io;
use ;
;
;
;
Run the server
use ;
let addr = new;
serve.run?;
Call from a client
use ;
let addr = new;
let pong: Pong = call.run?;
Compose multiple calls
use ;
let addr = new;
let both =
.flat_map;
let = both.run?;
Use the transport directly
use call_on;
use TcpTransport;
let transport = connect.run?;
let = .run?;
// transport is available for another call
let = .run?;
Architecture
client.rs call() and call_on() -- connection-per-request RPC
server.rs serve() -- bind + accept loop + thread-per-connection
serve.rs Serve trait -- Clone + Send + 'static, handle returns Io
transport.rs Transport trait -- linear state-threading, TcpTransport, ChannelTransport
codec.rs Length-delimited JSON framing over Read/Write
protocol.rs Wire types: RequestId newtype, Envelope sum type
error.rs Error enum with hand-rolled Display/Error/From
Building
Testing
Linting
RUSTFLAGS="-D warnings"
Documentation
Docs are auto-published to GitHub Pages on push to main via the workflow in .github/workflows/docs.yml. Enable in repo Settings > Pages > Source > GitHub Actions.
License
Licensed under either of
at your option.