nxtquic-api 0.1.2

High-level async API for NxtQuic
Documentation
# nxtquic-api

[![Crates.io](https://img.shields.io/crates/v/nxtquic-api.svg)](https://crates.io/crates/nxtquic-api)
[![Documentation](https://docs.rs/nxtquic-api/badge.svg)](https://docs.rs/nxtquic-api)
[![License: MIT OR Apache-2.0](https://img.shields.io/badge/License-MIT%20OR%20Apache--2.0-blue.svg)](https://github.com/nxtstream/nxtquic/blob/main/LICENSE.md)
[![Rust: 1.85+](https://img.shields.io/badge/Rust-1.85+-orange.svg)](Cargo.toml)

**High-level async API for NxtQuic.**

`nxtquic-api` is the ergonomic async/await layer of the [NxtQuic](https://crates.io/crates/nxtquic) workspace. It wraps the I/O-free `nxtquic-proto` state machine and the `nxtquic-udp` socket layer into a beautiful, Tokio-compatible API with familiar `AsyncRead` / `AsyncWrite` stream interfaces.

## Features

- **`Endpoint`** — bind a QUIC UDP endpoint as client or server
- **`Connection`** — manage a single QUIC connection with full lifecycle control
- **`SendStream` / `RecvStream`**`AsyncWrite` / `AsyncRead`-compatible bidirectional and unidirectional streams
- **Unreliable datagrams** — send/receive RFC 9221 datagrams through the same connection
- **Tokio runtime integration** — optional `tokio-runtime` feature (enabled by default)
- **TLS via `rustls`** — secure connections with zero-copy TLS session tickets

## Feature flags

| Flag | Default | Description |
|---|---|---|
| `tokio-runtime` | ✅ yes | Enable the Tokio-based async driver |

## Quick Start

```toml
[dependencies]
nxtquic-api = "0.1.2"
tokio = { version = "1", features = ["full"] }
```

```rust
use nxtquic_api::{Endpoint, ServerConfig};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let endpoint = Endpoint::server(server_config, "0.0.0.0:4433".parse()?).await?;
    while let Some(incoming) = endpoint.accept().await {
        let conn = incoming.accept().await?;
        tokio::spawn(handle_connection(conn));
    }
    Ok(())
}
```

For the full workspace including HTTP/3, WebTransport, and simulation, use the top-level [`nxtquic`](https://crates.io/crates/nxtquic) crate.

## Part of the NxtQuic workspace

| Crate | Purpose |
|---|---|
| [`nxtquic`]https://crates.io/crates/nxtquic | Top-level re-export, async API |
| [`nxtquic-proto`]https://crates.io/crates/nxtquic-proto | Core state machine |
| [`nxtquic-crypto`]https://crates.io/crates/nxtquic-crypto | Pluggable crypto backends |
| [`nxtquic-udp`]https://crates.io/crates/nxtquic-udp | Platform-optimized UDP I/O |
| **`nxtquic-api`** | **Tokio async/await API (this crate)** |
| [`nxtquic-h3`]https://crates.io/crates/nxtquic-h3 | HTTP/3 + QPACK |
| [`nxtquic-sim`]https://crates.io/crates/nxtquic-sim | Deterministic network simulator |
| [`nxtquic-qlog`]https://crates.io/crates/nxtquic-qlog | qlog structured logging |

## License

Licensed under either of [MIT](https://github.com/nxtstream/nxtquic/blob/main/LICENSE.md) or Apache-2.0 at your option.