#http-request #http-response #redirect #tcp #request-response

tcplane

tcplane is a lightweight and high-performance Rust TCP server library designed to simplify network service development. It supports TCP communication, data stream management, and connection handling, focusing on providing efficient low-level network connections and data transmission capabilities, making it ideal for building modern network services.

158 stable releases

Uses new Rust 2024

new 3.21.2 Apr 19, 2025
3.21.0 Apr 13, 2025
3.16.0 Mar 30, 2025
3.0.3 Feb 26, 2025
0.0.6 Jan 2, 2025

#1596 in Network programming

Download history 2057/week @ 2025-01-01 2264/week @ 2025-01-08 3091/week @ 2025-01-15 195/week @ 2025-01-22 137/week @ 2025-01-29 1241/week @ 2025-02-05 1488/week @ 2025-02-12 1282/week @ 2025-02-19 2731/week @ 2025-02-26 942/week @ 2025-03-05 503/week @ 2025-03-12 909/week @ 2025-03-19 862/week @ 2025-03-26 531/week @ 2025-04-02 515/week @ 2025-04-09

2,843 downloads per month

MIT license

31KB
763 lines

tcplane

Official Documentation

Api Docs

tcplane is a lightweight and high-performance Rust TCP server library designed to simplify network service development. It supports TCP communication, data stream management, and connection handling, focusing on providing efficient low-level network connections and data transmission capabilities, making it ideal for building modern network services.

Installation

To use this crate, you can run cmd:

cargo add tcplane

Use

use tcplane::*;

async fn test_func(ctx: Context) {
    ctx.send("tcplane").await.unwrap();
    let response: Response = ctx.get_response().await;
    let response_data: &ResponseData = response.get_response_data();
    ctx.log_debug(
        &format!(
            "Response => {:?}\n",
            String::from_utf8_lossy(&response_data)
        ),
        log_handler,
    )
    .await;
}

#[tokio::main]
async fn main() {
    let mut server: Server = Server::new();
    server.host("0.0.0.0").await;
    server.port(60000).await;
    server.log_dir("./logs").await;
    server.log_size(100_024_000).await;
    server.buffer(100_024_000).await;
    server.func(test_func).await;
    let test_string: String = "test".to_owned();
    server
        .func(async_func!(test_string, |data| {
            println_success!(&test_string);
            println_success!(String::from_utf8_lossy(&data.get_request().await));
        }))
        .await;
    server.listen().await;
}

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

Contact

For any inquiries, please reach out to the author at ltpp-universe root@ltpp.vip.

Dependencies

~7–14MB
~166K SLoC