Agnostic abstraction layer of std::net for any async runtime.
Introduction
agnostic-net provides runtime-agnostic abstractions for TCP and UDP networking. Write your network code once and run it with tokio, or smol - without any code changes.
Key Features
- TCP Support: Async TCP listeners and streams
- UDP Support: Async UDP sockets
- Cross-Platform: Works on Unix, Windows, and other platforms
- Runtime Agnostic: Seamlessly switch between tokio, and smol
- Zero-Cost: Compiles to runtime-specific code
- Familiar API: Similar to
std::netbut async
Supported Runtimes
- tokio - Enable with
features = ["tokio"] - smol - Enable with
features = ["smol"]
Installation
[]
= "0.3"
-
tokio= { = "0.3", = ["tokio"] } -
smol= { = "0.3", = ["smol"] }
Platform Support
agnostic-net works on all major platforms:
- Unix/Linux: Full support via
rustix - Windows: Full support via
windows-sysandsocket2 - macOS: Full support
- BSD: Full support
Feature Flags
std(default): Standard library supporttokio: Tokio runtime supporttokio-io: Tokio I/O trait implementationssmol: Smol runtime support
Performance Considerations
- Zero-cost abstractions: Compiles to runtime-specific code
- No runtime overhead: Direct delegation to underlying runtime
- Efficient I/O: Uses platform-specific optimizations
License
agnostic-net 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.