tokio-rs/mio
66.7
Adequate · 29 September 2026
12.1k
lines of production code
Rust
primary language
2
measurements over time
What this system is
Mio is a low-level I/O library for Rust that provides non-blocking TCP, UDP, and Unix domain socket networking primitives. It manages event readiness polling and cross-thread notifications through a centralized Poll and Registry system, abstracting platform-specific selectors like epoll, kqueue, and IOCP. The library supports a wide range of operating systems, including Unix variants, Windows, and WASI, while offering feature-gated modules to allow for minimal builds.
How it got here
2014–2015 — Mio v1.0 API redesign and platform consolidation
6 changes.
This period focused on a major API redesign for Mio v1.0, replacing the legacy event-driven model with a modern, non-blocking Poll and Registry system. The codebase was restructured to consolidate platform-specific implementations into dedicated sys modules for Unix, Windows, and WASI, while upgrading dependencies to the Rust 2021 edition and windows-sys.
2019–2024 — Unix domain socket support and internal refactoring
10 changes.
This period focused on adding comprehensive Unix domain socket support across multiple platforms while refactoring core networking types to use a centralized IoSource adapter. Significant internal changes included reorganizing event handling traits, modernizing file descriptor management with OwnedFd, and splitting selector backends to handle stateful bookkeeping. The work was complemented by extensive test coverage, new network examples, and the introduction of a shell backend for unsupported targets.
Features
Add Unix Domain Socket (UDS) support for Unix systems
This change introduces the \sys::unix::uds\ module, providing the underlying system-level implementation for Unix Domain Sockets. It adds support for \UnixStream\, \UnixListener\, and \UnixDatagram\ across a wide range of Unix-like operating systems, including Linux, macOS, FreeBSD, Android, and several embedded or niche targets (e.g., ESP-IDF, Haiku, AIX). The implementation handles platform-specific nuances such as abstract namespaces on Linux/Android, fallback to \accept()\ on platforms lacking \accept4()\, and consistent file descriptor handling (CLOEXEC, non-blocking) to ensure robustness and portability.
src/sys/unix/uds · high confidence
Add Unix domain socket support for Unix systems
This change introduces new \UnixStream\, \UnixListener\, and \UnixDatagram\ types in the \src/net/uds\ module, enabling non-blocking I/O on Unix domain sockets. These types wrap the standard library's \std::os::unix::net\ equivalents using an internal \IoSource\ helper to manage event registration and \WouldBlock\ handling via the \try\_io\ method. The implementation provides standard socket operations such as binding, connecting, accepting, sending, and receiving data, along with conversions to and from standard library types and file descriptor traits.
src/net/uds · high confidence
Added shell system backend as a placeholder for unsupported targets
A new \sys::shell\ module has been introduced to serve as a stub implementation for operating systems or configurations that do not support the primary polling and networking backends. This module provides no-op implementations for the selector, waker, TCP, UDP, and Unix domain socket subsystems; all public methods panic at runtime with a message instructing the user to compile with the \os-poll\ feature. This ensures that builds on unsupported targets fail fast with a clear error rather than exhibiting undefined behavior or linking errors.
src/sys/shell · high confidence
New TCP and UDP server examples for network programming
Added three new example programs in the \examples\ directory to demonstrate network I/O patterns: \tcp\_server.rs\ (a standard TCP echo server binding to 127.0.0.1:9000), \tcp\_listenfd\_server.rs\ (a TCP server that accepts a pre-opened file descriptor via the \LISTEN\_FDS\ environment variable, supporting WASI and HermitOS), and \udp\_server.rs\ (a UDP echo server). These examples illustrate how to use \mio::Poll\, \TcpListener\, \TcpStream\, and \UdpSocket\ with non-blocking I/O, event registration, and proper handling of \WouldBlock\ and \Interrupted\ errors.
examples · high confidence
Architecture
Reorganize system-specific code into a dedicated sys module
The library now isolates platform-dependent implementations (Unix, Windows, WASI, and a shell fallback) within a new \src/sys\ module. This structural change consolidates system-specific types like \Selector\, \Event\, and \IoSource\ into a single location, simplifying the public API surface and making it easier to maintain or extend support for different operating systems.
src/sys · high confidence
Reorganized networking types into the \`mio::net\` module
The networking primitives (TcpListener, TcpStream, UdpSocket, and Unix domain sockets) have been moved into a dedicated \src/net\ module. This change restructures the public API surface, grouping these types under \mio::net\ for better organization and clarity, while maintaining their existing functionality and non-blocking behavior.
src/net · high confidence
Behavioural changes
Mio v1.0: Complete API redesign with feature-gated modules
This release introduces a breaking API redesign for Mio, replacing the legacy \Reactor\ and \Handler\ traits with a modern, non-blocking \Poll\ and \Registry\ system. The old event-driven callback model is removed in favor of explicit readiness polling and an \Interest\ bitmask for registering sources. The crate is now structured around feature flags (\os-poll\, \os-ext\, \net\) to allow minimal builds, and introduces new core types like \Token\, \Waker\, and \IoSource\ to manage event sources and cross-thread notifications. Platform-specific code is consolidated into \sys\ modules, and the public API is reorganized into distinct \event\, \net\, and platform-specific (\unix\, \windows\, \wasi\) modules.
src · high confidence
New event readiness detection methods and Source trait reorganization
The event module now exposes \is\_read\_closed\ and \is\_write\_closed\ methods on \Event\, allowing users to detect when the read or write half of a socket has been closed by the peer or local stream. The \Event\ struct is now \Clone\, and its iterator returns references to events rather than owned copies. The \Evented\ trait has been renamed to \event::Source\, and its registration methods (\register\, \reregister\, \deregister\) now take a mutable reference to the source instead of an immutable one, requiring callers to update their implementations accordingly.
src/event · high confidence
Refactor TCP networking types to use IoSource
The \TcpListener\ and \TcpStream\ types in \src/net/tcp\ have been restructured to wrap the standard library's \net::TcpListener\ and \net::TcpStream\ inside a new \IoSource\ adapter. This change centralizes I/O safety and event registration logic, allowing the TCP types to implement traits like \AsFd\ and \IntoRawFd\ more consistently across Unix, Windows, and HermitOS. For users, the public API surface remains largely compatible, but the underlying implementation now relies on \IoSource\ for handling raw file descriptor/socket conversions and non-blocking I/O operations.
src/net/tcp · high confidence
Refactor selector backends to use OwnedFd and split IoSourceState by statefulness
The Unix selector implementations (epoll, kqueue, event\_ports, and poll) now manage file descriptors using std::os::fd::OwnedFd instead of raw integers, ensuring automatic cleanup and preventing leaks. To support backends that require user-space bookkeeping (poll and event\_ports), the codebase introduces a stateful IoSourceState implementation that tracks registration records and handles internal deregistration on closed fds, while stateless backends (epoll and kqueue) use a lightweight pass-through IoSourceState.
src/sys/unix/selector · high confidence
Refactored Unix waker implementations into dedicated modules
The Unix waker logic has been reorganized into separate, platform-specific modules (eventfd, pipe, selector, and single\_threaded) within the sys::unix::waker directory. This change extracts the underlying mechanisms for waking I/O selectors—such as using eventfd counters, Unix pipes, or selector-specific wake calls—into distinct files, improving code maintainability and clarity for each operating system's requirements without altering the external API.
src/sys/unix/waker · high confidence
Rewritten Windows I/O implementation using windows-sys
The Windows system backend has been completely rewritten to replace the legacy winapi/miow dependencies with the windows-sys crate. This change introduces a new internal architecture for handling asynchronous I/O, including a dedicated AFD (Ancillary Functions for Winsock) driver interface for polling, a refined I/O Completion Port (IOCP) wrapper, and a new readiness-based event model that bridges the gap between completion-based IOCP and readiness-based selectors. Users benefit from improved stability, better error handling for named pipes and TCP/UDP sockets, and a more robust foundation for cross-platform compatibility.
src/sys/windows · high confidence
Unix platform support consolidated into sys::unix module
The internal Unix implementation has been reorganized into a dedicated \src/sys/unix\ module, centralizing platform-specific logic for socket creation, TCP/UDP operations, and pipe handling. This change introduces a unified \syscall!\ macro for error handling, standardizes non-blocking socket setup across diverse OS families (including Apple, BSD, Linux, and AIX), and adds support for new Unix-like targets such as ESP-IDF, NuttX, and Vita. It also exposes the \SourceFd\ adapter for registering arbitrary file descriptors and implements a cross-platform \pipe\ module for inter-process communication, while ensuring consistent behavior for socket options like \SO\_NOSIGPIPE\ and \O\_NONBLOCK\.
src/sys/unix · high confidence
Test coverage
Comprehensive test suite for I/O sources and polling behavior; New test utilities for event readiness and polling assertions.
Dependencies
Mio 1.2.3: Upgrade to Rust 2021 Edition and windows-sys 0.61
This release updates the project to the Rust 2021 edition and raises the minimum supported Rust version (MSRV) to 1.71. It upgrades the Windows dependency from windows-sys 0.60 to 0.61 and the Unix dependency libc to 0.2.183. The package also removes the nix dependency, adds wasi 0.11.0 for WASI targets, and updates dev-dependencies including env\_logger to 0.11 and rand to 0.9.
(dependencies) · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Score
- CAI 65 → 67 (+1.4)
- Rubric changed (rubric-2026.09.9 → rubric-2026.09.18) — scores are not directly comparable.
Lenses
- Code Health 95 → 95 (+0.0)
- Architecture 93 → 88 (-4.4)
- Maturity 58 → 58 (+0.1)
- Readiness 78 → 74 (-4.0)
- Security 57 → 68 (+10.8)
Resolved (4)
- Boundary-crossing change coupling: stream.rs ↔ sourcefd.rs (src/net/tcp/stream.rs)
- Change coupling: stream.rs ↔ udp.rs (src/net/tcp/stream.rs)
- Hotspot: src/sys/unix/selector/event_ports.rs (src/sys/unix/selector/event_ports.rs)
- Off-boarding risk: anonymized user #1
New (7)
- Dependency hygiene PARTLY measured — Cargo dependencies read, no committed lock to grade for currency
- Inverted test pyramid
- Off-boarding risk: anonymized user #1
- Projects may be oversized for their cohesion
- Redundant deregistration API: Source.deregister delegates to Registry.deregister, creating a confusing dual-entry point for the same operation.
- Redundant re-registration API: Source.reregister delegates to Registry.reregister, creating a confusing dual-entry point for the same operation.
- Redundant registration API: Source.register delegates to Registry.register, creating a confusing dual-entry point for the same operation.
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
tokio-rs/mio was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 29 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit da425f909dd6b86d887da9eaefcb158099b5b165 — the exact code this score is about.
- Scored under rubric-2026.09.18 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-c4983f2d4e5c.