rs-netty 1.1.0

A Tokio-native typed TCP/UDP pipeline framework inspired by Netty.
Documentation
use rs_netty::{codec::LineCodec, handler, pipeline, Result, TcpClient};

#[tokio::main]
async fn main() -> Result<()> {
    let client = TcpClient::connect("127.0.0.1:9000")
        .pipeline(|| {
            let pipeline = pipeline().codec(LineCodec::new()).handler(PrintResponse);
            pipeline
        })
        .run()
        .await?;

    client.write_and_flush("hello".to_string()).await?;
    client.write_and_flush("world".to_string()).await?;
    tokio::time::sleep(std::time::Duration::from_millis(200)).await;
    client.close().await?;
    client.wait().await
}

struct PrintResponse;

#[handler(PrintResponse, write = String)]
async fn print_response(msg: String) -> Result<()> {
    println!("server -> {msg}");
    Ok(())
}