ztx

Crates.ioztx
lib.rsztx
version1.0.0
created_at2025-09-05 12:11:04.006316+00
updated_at2025-09-05 12:11:04.006316+00
descriptionZTX is a simple & fast RoQ (RPC over QUIC) framework built using TQUIC
homepage
repositoryhttps://github.com/Akzestia/ztx
max_upload_size
id1825422
size67,973
アクゼスティア (Akzestia)

documentation

README

ZTX

ZTX - a simple, 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

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

Commit count: 55

cargo fmt