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.
To use this crate, you can run cmd:
cargo add tcplane
use tcplane::*;
async fn test_func(controller_data: ControllerData) {
controller_data.send("Tcplane").await.unwrap();
let response: Response = controller_data.get_response().await;
let response_data: &ResponseData = response.get_response_data();
controller_data
.log_debug(
format!(
"Response => {:?}\n",
String::from_utf8_lossy(&response_data)
),
log_debug_format_handler,
)
.await;
}
async fn run_server() {
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.log_interval_millis(360).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!(&format!("{:?}", data));
}))
.await;
server.listen().await;
}
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please open an issue or submit a pull request.
For any inquiries, please reach out to the author at ltpp-universe root@ltpp.vip.