#rpc-framework #quic #roq #rpc #framework

macro zetax_macro

ZTX is a simple & fast RoQ (RPC over QUIC) framework built using TQUIC

1 unstable release

Uses new Rust 2024

0.1.0 Sep 5, 2025

#6 in #roq

Download history 117/week @ 2025-09-03 19/week @ 2025-09-10 18/week @ 2025-09-17 10/week @ 2025-09-24 23/week @ 2025-10-01 23/week @ 2025-10-15

57 downloads per month
Used in 2 crates

MIT license

7KB
106 lines

ZTX

Crates.io Crates.io Crates.io Crates.io

ZTX - a simple, blazingly fast RoQ (RPC over QUIC) framework, built using TQUIC.

Performance

ZTX can be as fast as 4x the speed of gRPC, but you should note that ZTX contains a wide range of specific optimizations, so creating a fair benchmark is a bit complicated

Usage

[!TIP] See examples for basic ztx client/server implementation

Setting up server

fn main() -> Result<()> {
    register_rpc(&RPC_ECHO);
    register_rpc(&RPC_HELLO);

    let settings = ServerSettings::builder()
        .workers(num_cpus::get())
        .listen("0.0.0.0:4433".parse().unwrap())
        .cert_file("cert.crt")
        .key_file("cert.key")
        .build();

    run_server(settings)
}

Register RPC (Server side)

// Define echo RPC
#[rpc("echo")]
pub async fn echo(_ctx: RpcContext, input: Vec<u8>) -> RpcResult<Vec<u8>> {
    Ok(input)
}

// Register RPC
fn main() -> Result<()> {
    // You must register ALL of your defined RPCs before run_server()
    register_rpc(&RPC_ECHO);

    // Server setup
    // ...
    run_server(settings)
}

Setting up client

#[tokio::main]
async fn main() -> Result<()> {
    let server: SocketAddr = "127.0.0.1:4433".parse().unwrap();
    // Optional: log connection
    info!("connecting to {}", server);

    let mut client = QuicRpcClient::builder(server).idle_timeout(5_000).build()?;
}

Calling RPC (Client side)

// RPC with payload
let resp = client.call_with("echo", b"hello world")?;
println!("echo => {}", String::from_utf8_lossy(&resp));
// RPC without payload
let _ = client.call("ping")?;

Docs

More info available in docs folder

License MIT

Dependencies

~160–570KB
~13K SLoC