Expand description
Agnostic Network
§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
[dependencies]
agnostic-net = "0.3"-
tokioagnostic-net = { version = "0.3", features = ["tokio"] } -
smolagnostic-net = { version = "0.3", features = ["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.
Re-exports§
pub use agnostic_lite as runtime;pub use agnostic_io as io;
Modules§
- os
- Operating system specific types and traits.
Traits§
- Net
- An abstraction layer for the async runtime’s network.
- Owned
Read Half - The abstraction of a owned read half of a TcpStream.
- Owned
Write Half - The abstraction of a owned write half of a TcpStream.
- Reunite
Error - Error indicating that two halves were not from the same socket, and thus could not be reunited.
- TcpListener
- An abstraction layer for TCP listener.
- TcpStream
- The abstraction of a TCP stream.
- ToSocket
Addrs - Converts or resolves without blocking base on your async runtime to one or more
SocketAddrvalues. - UdpSocket
- The abstraction of a UDP socket.