Crate rust_tcp_sever

Source
Expand description

A simple and lightweight asynchronous TCP server crate.

§Install

Paste this text into your Cargo.toml:

rust_tcp_sever = "0.3.0"

or

cargo add rust_tcp_sever

§Examples

#[tokio::main]
async fn main() {
    HttpServer::launch(TcpListener::bind("127.0.0.1:80").await.unwrap(), work).await;
}

async fn work(request: Request) -> Response {
    Response::from_response("200 OK", "All Good :)")
}

or

use rust_tcp_sever::*;

#[tokio::main]
async fn main() {
    CleanServer::launch(TcpListener::bind("127.0.0.1:80").await.unwrap(), work).await;
}

async fn work(stream: TcpStream) {}

§Supported Protocols

§Feature flags

  • get_stream: Adds a socket_addr field to the Request.
  • check_stream: Allows you to implement custom security measures by enabling address verification logic in HttpServer::launch.

Re-exports§

pub use crate::clean::server::*;
pub use crate::http::request::*;
pub use crate::http::response::*;
pub use crate::http::server::*;

Modules§

clean
Clean server.
http
HTTP server.
rest
The remaining files for the server to work.

Macros§

set_def_pages
Set DEF_PAGES.

Structs§

TcpListener
A TCP socket server, listening for connections.
TcpStream
A TCP stream between a local and a remote socket.