# Extension points — tokio-rs/tokio

> Canonical page: https://codevetter.com/unpack/tokio/extension-points

# Extension points — tokio-rs/tokio

Scanned commit 2746c3ae26f8ac0af6023843a7f23d419c334efe (2026-10-02). Generated by codevetter codevetter 1.15.0 on 2026-10-02.

Source inspection; upstream code and tests were not executed.

The principal extension mechanism is Rust trait composition, supplemented by builders and adapters. Custom transports implement async I/O traits; custom protocols implement codec traits. Runtime hooks permit instrumentation, while stream wrappers and maps integrate additional event sources. Feature and platform gates define extension boundaries, and some interfaces are deliberately sealed or unstable.
- Custom transports implement AsyncRead::poll_read and AsyncWrite::poll_write/poll_flush, including arranging waker notifications when returning Pending. — [tokio/src/io/async_read.rs#L44-L59](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio/src/io/async_read.rs#L44-L59) [tokio/src/io/async_write.rs#L39-L67](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio/src/io/async_write.rs#L39-L67)
- Protocol codecs implement Decoder with Item/Error and Encoder<Item>; Decoder provides EOF handling, while Encoder writes into the framing layer's BytesMut buffer. — [tokio-util/src/codec/decoder.rs#L35-L54](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio-util/src/codec/decoder.rs#L35-L54) [tokio-util/src/codec/decoder.rs#L124-L155](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio-util/src/codec/decoder.rs#L124-L155) [tokio-util/src/codec/encoder.rs#L8-L24](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio-util/src/codec/encoder.rs#L8-L24)
- Builder instrumentation stores Send + Sync thread-start callbacks; on_before_task_poll receives TaskMeta and is additionally gated by tokio_unstable. — [tokio/src/runtime/builder.rs#L768-L775](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio/src/runtime/builder.rs#L768-L775) [tokio/src/runtime/builder.rs#L1014-L1021](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio/src/runtime/builder.rs#L1014-L1021)
- TcpStream::from_std bridges externally created sockets into Mio/PollEvented; callers must provide nonblocking sockets and an entered runtime with I/O enabled. — [tokio/src/net/tcp/stream.rs#L183-L199](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio/src/net/tcp/stream.rs#L183-L199) [tokio/src/net/tcp/stream.rs#L216-L230](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio/src/net/tcp/stream.rs#L216-L230)
- ReceiverStream adapts an mpsc Receiver by forwarding poll_next to poll_recv; StreamMap accepts replacement streams by key and emits keyed Stream items. — [tokio-stream/src/wrappers/mpsc_bounded.rs#L39-L47](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio-stream/src/wrappers/mpsc_bounded.rs#L39-L47) [tokio-stream/src/wrappers/mpsc_bounded.rs#L65-L70](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio-stream/src/wrappers/mpsc_bounded.rs#L65-L70) [tokio-stream/src/stream_map.rs#L446-L453](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio-stream/src/stream_map.rs#L446-L453) [tokio-stream/src/stream_map.rs#L669-L682](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio-stream/src/stream_map.rs#L669-L682)
- Command::spawn_with permits custom standard-process spawning while reusing child wrapping; the implementation notes this API is behind tokio_unstable. — [tokio/src/process/mod.rs#L934-L961](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio/src/process/mod.rs#L934-L961)
- New public capability wiring belongs in crate feature tables and gated module exports; tokio-util independently maps features to Tokio dependencies and utility modules. — [tokio/Cargo.toml#L24-L92](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio/Cargo.toml#L24-L92) [tokio-util/Cargo.toml#L19-L33](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio-util/Cargo.toml#L19-L33) [tokio-util/src/lib.rs#L25-L55](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio-util/src/lib.rs#L25-L55)
- ToSocketAddrs inherits a sealed private trait, so address resolution is not an open downstream implementation hook; inspected string implementations choose immediate parsing or blocking DNS. — [tokio/src/net/addr.rs#L19-L19](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio/src/net/addr.rs#L19-L19) [tokio/src/net/addr.rs#L162-L184](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio/src/net/addr.rs#L162-L184) [tokio/src/net/addr.rs#L262-L262](https://github.com/tokio-rs/tokio/blob/2746c3ae26f8ac0af6023843a7f23d419c334efe/tokio/src/net/addr.rs#L262-L262)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
