ntex 4.0.0-beta.17

Framework for composable network services
docs.rs failed to build ntex-4.0.0-beta.17
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: ntex-4.0.0-beta.14

Linux crates.io Documentation MSRV License codecov Discord

ntex provides a strongly typed component for building asynchronous network applications. It includes HTTP/1, HTTP/2, WebSocket, Mqtt3/5, Amqp1.0, TLS, and runtime-independent I/O support.

Build status

Platform Status
Linux Linux
macOS macOS
Windows Windows

Usage

Add ntex to your project:

[dependencies]
ntex = "4"

A minimal web server looks like this:

use ntex::{SharedCfg, web};

#[web::get("/")]
async fn index() -> &'static str {
    "Hello world!"
}

#[ntex::main]
async fn main() -> std::io::Result<()> {
    web::HttpServer::new(async |_| wev::App::new().service(index))
        .bind("127.0.0.1:8080", SharedCfg::new("hello-world"))?
        .run()
        .await
}

Runtime selection

Without an explicit runtime feature, ntex uses its native single-threaded runtime and automatically selects a platform I/O reactor:

  • Linux tries io_uring and falls back to polling.
  • Other Unix platforms use polling.
  • Windows uses IOCP.

Alternative runtimes and native reactors can be selected with Cargo features:

Feature Runtime or reactor
tokio Tokio local runtime and I/O driver
compio Compio runtime and completion-based I/O
neon-polling Native runtime with the polling reactor on Unix
neon-uring Native runtime with io_uring on Linux

Enable at most one runtime or native-reactor selection feature. For example:

[dependencies]
ntex = { version = "4", features = ["tokio"] }

Optional features

  • openssl and rustls enable the corresponding TLS integrations.
  • compress enables HTTP content compression.
  • cookie enables cookie support.
  • url enables URL parsing support.
  • ws enables WebSocket APIs and is enabled by default.

Documentation and community

License

This project is licensed under either of: