agnostic-io defines I/O traits in Sans-I/O style for any async runtime.
Introduction
agnostic-io provides runtime-agnostic I/O traits following the Sans-I/O design philosophy. It defines standardized async I/O interfaces that work across tokio, smol, and other runtimes without coupling your protocol implementations to specific I/O primitives.
What is Sans-I/O?
Sans-I/O (French for "without I/O") is a design pattern that separates protocol logic from I/O implementation. Instead of tightly coupling your code to specific I/O libraries, you:
- Define abstract I/O traits (what
agnostic-ioprovides) - Implement your protocol logic against these traits
- Let runtime-specific implementations handle the actual I/O
This approach makes your code:
- Testable: Mock I/O without real sockets
- Portable: Works with any async runtime
- Reusable: Protocol implementations work everywhere
- Maintainable: Changes to I/O layer don't affect protocol logic
Key Features
- Runtime Agnostic: Works with tokio, smol, and more
no_stdCompatible: Can be used in embedded environments- Zero-Cost: Trait-based design compiles away
- Comprehensive: AsyncRead, AsyncWrite, AsyncSeek, and more
- Tokio Compatible: Optional compatibility layer for tokio traits
Installation
[]
= "0.2"
Feature Flags
# Standard library support (default)
= { = "0.1", = ["std"] }
# Allocation support without std
= { = "0.1", = false, = ["alloc"] }
# Tokio I/O trait compatibility
= { = "0.1", = ["tokio"] }
# no_std without allocations
= { = "0.1", = false }
Tokio Compatibility
When using the tokio feature, agnostic-io provides compatibility with tokio::io traits:
[]
= { = "0.1", = ["tokio"] }
Feature Flags
std(default): Standard library supportalloc: Allocation support without stdtokio: Compatibility with tokio::io traits
License
agnostic-io is under the terms of both the MIT license and the
Apache License (Version 2.0).
See LICENSE-APACHE, LICENSE-MIT for details.
Copyright (c) 2025 Al Liu.