# API Map
This chapter lists important public APIs by module. `pub(crate)` runtime details are not listed as user APIs.
## crate root
- `pipeline()`: creates a TCP stream typed pipeline builder.
- `datagram_pipeline()`: creates a UDP datagram typed pipeline builder.
- `TcpServer` / `TcpClient`: TCP server/client builders.
- `UdpServer` / `UdpClient`: UDP server/client builders.
- `Channel` / `DatagramChannel`: cloneable external write/flush/close handles.
- `Context` / `DatagramContext`: final handler context for writing and connection/socket operations.
- `InboundContext` / `BusinessContext` / `OutboundContext`: read-only identity contexts for transform stages. With the `tls` feature, TCP stream contexts can expose negotiated TLS metadata with `tls()`.
- `Life` / `NoLife` / `CloseReason`: lifecycle hook API.
- `Error` / `Result`: framework error type and result alias.
- `Flow`: continue or stop a stage's current message.
- `handler`: attribute macro re-exported with the `macros` feature.
- `TlsContextBuilder` / `ServerTlsContext` / `ClientTlsContext` / `TlsInfo`: TLS context and metadata APIs behind the `tls` feature.
## `traits`
- `Flow<T>`: `Next(T)` continues the pipeline; `Stop` consumes the message.
- `Inbound<I>`: inbound transform stage returning `Flow<Out>`.
- `Business<I>`: business transform stage between inbound and the final handler.
- `Handler<I>`: TCP final inbound handler with `type Write`.
- `DatagramHandler<I>`: UDP final inbound handler with `type Write`.
- `Outbound<I>`: outbound transform stage that converts handler writes into codec-encodable values.
## `codec`
- `Decoder`: TCP byte stream decoder returning `Option<Item>`.
- `Encoder<I>`: TCP byte stream encoder.
- `DatagramDecoder`: UDP datagram decoder.
- `DatagramEncoder<I>`: UDP datagram encoder.
- `LineCodec`: UTF-8 newline-delimited stream codec.
- `ByteArrayDecoder`: drains the current stream buffer into `Bytes`, and can encode `Bytes`.
- `ByteArrayEncoder`: pass-through `Bytes` encoder.
- `FixedLengthFrameDecoder`: fixed-size binary frame codec.
- `DelimiterBasedFrameDecoder`: delimiter-terminated binary frame codec.
- `LengthFieldBasedFrameDecoder`: length-field frame decoder that can also encode zero-offset/zero-adjustment `Bytes`.
- `LengthFieldPrepender`: `Bytes` encoder that prepends a length field.
- `ByteOrder`: endian setting used by length-field codecs.
- `Utf8DatagramCodec`: UTF-8 datagram codec.
- `BytesDatagramCodec`: raw bytes datagram codec.
- `JsonDecode<T>`: inbound JSON stage behind the `json` feature.
- `JsonEncode<T>`: outbound JSON stage behind the `json` feature.
- `HttpCodec`: minimal HTTP/1.1 request/response server codec.
- `HttpRequest`: HTTP request view with method/target/version/header/body/trailer accessors.
- `HttpResponse`: HTTP response builder with status/reason/header/body.
- `MqttCodec`: MQTT 5 packet stream codec.
- `MqttPacket`: MQTT control packet enum.
- `QoS`: MQTT QoS enum.
- `ConnectPacket` / `ConnAckPacket` / `PublishPacket` / `AckPacket`: common MQTT packet structs.
- `SubscribePacket` / `SubAckPacket` / `UnsubscribePacket` / `UnsubAckPacket`: MQTT subscribe/unsubscribe packet structs.
- `DisconnectPacket` / `AuthPacket` / `Will` / `MqttProperty`: MQTT helper packet/property types.
- `WebSocketCodec`: server-side WebSocket codec behind the `websocket` feature.
- `HttpWsCodec`: HTTP + WebSocket shared-port codec behind the `websocket` feature.
- `WebSocketInbound` / `WebSocketOutbound` / `WebSocketMessage`: WebSocket message enums.
- `HttpWsInbound` / `HttpWsOutbound`: message enums for the shared HTTP/WebSocket codec.
- `WebSocketHandshake` / `WebSocketHandshakeResponse` / `WebSocketClose`: WebSocket handshake and close types.
- `HttpService` / `WebSocketService`: static service traits used by `HttpWsRouter`.
- `HttpWsRouter<H, W>`: combines an HTTP service and WebSocket service into one `Handler<HttpWsInbound>`.
## `context`
- `ConnInfo`: TCP connection id, peer address, local address, and negotiated TLS metadata when the `tls` feature is enabled.
- `DatagramInfo`: UDP socket id, current peer address, local address, and optional TCP-derived TLS metadata for stream transformation contexts when the `tls` feature is enabled.
- `ConnectionStats`: TCP connection counter snapshot handle.
- `Context<W>`: TCP handler context with `write`, `flush`, `write_and_flush`, `close`, `channel`, `stats`, and `tls` when the `tls` feature is enabled.
- `DatagramContext<W>`: UDP handler context with current-peer and explicit-peer write/flush/close operations.
- `InboundContext`: identity context for inbound stages, including `tls` for TLS TCP connections.
- `BusinessContext`: identity context for business stages, including `tls` for TLS TCP connections.
- `OutboundContext`: identity context for outbound stages, including `tls` for TLS TCP connections.
## `channel`
- `Channel<W>`: TCP external handle with identity, queue capacity, stats, write/flush/write_and_flush/close.
- `DatagramChannel<W>`: UDP external handle with socket identity, queue capacity, write_to/flush/write_to_and_flush/close.
## `life`
- `CloseReason`: TCP connection close reason.
- `NoLife`: default no-op lifecycle hooks.
- `Life`: lifecycle hook trait for servers, connections, and UDP sockets.
## `tls`
- `TlsContextBuilder::for_server()`: starts a server TLS context builder.
- `TlsContextBuilder::for_client()`: starts a typestate client TLS context builder in `NoTrust` state.
- `ServerTlsContextBuilder`: accepts certificate chain, private key, required or optional client-auth roots, ALPN protocols, and SNI-specific identities, then builds `ServerTlsContext`.
- `ClientTlsContextBuilder<NoTrust>`: accepts server-name overrides and trust strategy methods, but has no `build`.
- `ClientTlsContextBuilder<HasTrust>`: builds `ClientTlsContext` after roots or a verifier have been selected, can attach an mTLS client identity with `client_identity_pem` / `client_identity_der`, and can advertise ALPN protocols.
- `TlsInfo`: negotiated TLS metadata available from TCP `Context::tls`, stream stage contexts, and `ConnInfo::tls`. It exposes peer certificates, selected ALPN, and the client/server name used by the connection.
- `client_auth_required_pem` / `client_auth_required_der`: require client certificates signed by trusted roots.
- `client_auth_optional_pem` / `client_auth_optional_der`: allow clients without certificates, but verify a certificate when one is presented.
- `alpn_protocols`: configures advertised ALPN protocols on client or server contexts. Protocol names must be non-empty and at most 255 bytes.
- `sni_certificate_pem` / `sni_certificate_der`: add SNI-specific server certificate identities. A default certificate can be configured as fallback with `certificate_chain_*` plus `private_key_*`.
- `native_roots`, `webpki_roots`, and `danger_accept_invalid_certs` are gated by `tls-native-roots`, `tls-webpki-roots`, and `tls-dangerous`.
## `pipeline::stream`
- `builder::pipeline()`: TCP builder entry point.
- `builder::PipelineBuilder<...>`: TCP builder carrying stage state and message types.
- `builder::IntoStreamPipeline`: converts a ready builder into a runtime stream pipeline.
- `builder::IntoPipeline`: compatibility conversion trait for stream pipelines.
- `runtime::StreamPipeline<...>`: TCP runtime pipeline type, usually not named directly.
- `runtime::Pipeline<...>`: compatibility type alias for `StreamPipeline`.
- `runtime::StreamRuntimePipeline`: public bound required by TCP transport to run typed pipelines.
- `runtime::RuntimePipeline`: compatibility alias trait for `StreamRuntimePipeline`.
## `pipeline::datagram`
- `builder::datagram_pipeline()`: UDP builder entry point.
- `builder::DatagramPipelineBuilder<...>`: UDP builder carrying stage state and message types.
- `builder::IntoDatagramPipeline`: converts a ready builder into a runtime datagram pipeline.
- `runtime::DatagramPipeline<...>`: UDP runtime pipeline type, usually not named directly.
- `runtime::DatagramRuntimePipeline`: public bound required by UDP transport to run typed pipelines.
## `pipeline::core`
- `Identity`: empty stage pipe that forwards values unchanged.
- `Then<A, B>`: statically composes two stage pipes.
- `PipeStep<T, F>`: ready/future stage step used by runtime optimizations.
- `InboundPipe<I>` / `BusinessPipe<I>` / `OutboundPipe<I>`: internal stage-chain processing traits exposed because they appear in builder/runtime bounds.
- `Start` / `InboundPhase` / `BusinessPhase` / `Ready`: builder state markers.
## `transport::tcp`
- `TcpConnectionConfig`: TCP connection configuration.
- `TcpServerConfig` / `ServerConfig`: type aliases for `TcpConnectionConfig`.
- `TcpClientConfig`: type alias for `TcpConnectionConfig`.
- `TcpServer<F, L>`: TCP server builder.
- `TcpServer::tls`: enables server-side TLS when the `tls` feature is enabled.
- `TcpServerHandle`: server shutdown/wait handle.
- `TcpClient<F, L>`: TCP client builder.
- `TcpClient::tls`: enables client-side TLS when the `tls` feature is enabled.
- `TcpClientHandle<W>`: active TCP client handle.
- `PipelineFactory<F>`: wrapper for reusable client pipeline factories.
- `PipelineInstance<B>`: wrapper for single-use client pipelines.
## `transport::udp`
- `UdpSocketConfig`: UDP socket configuration.
- `UdpServerConfig` / `UdpClientConfig`: type aliases for `UdpSocketConfig`.
- `UdpServer<F, L>`: UDP server socket builder.
- `UdpServerHandle`: UDP server shutdown/wait handle.
- `UdpClient<F, L>`: UDP client socket builder.
- `UdpClientHandle<W>`: active UDP client handle.
## `client` And `server`
- `client::TcpClient` / `client::TcpClientHandle` / `client::TcpClientConfig`: TCP re-exports under the client module.
- `client::UdpClient` / `client::UdpClientHandle` / `client::UdpClientConfig`: UDP re-exports under the client module.
- `server::TcpServer` / `server::TcpServerHandle` / `server::TcpServerConfig` / `server::ServerConfig`: TCP re-exports under the server module.
- `server::UdpServer` / `server::UdpServerHandle` / `server::UdpServerConfig`: UDP re-exports under the server module.