agnostic-net 0.3.0

Agnostic abstraction layer of `std::net` for any async runtime.
Documentation

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::net but async

Supported Runtimes

  • tokio - Enable with features = ["tokio"]
  • smol - Enable with features = ["smol"]

Installation

[dependencies]
agnostic-net = "0.3"
  • tokio

    agnostic-net = { version = "0.3", features = ["tokio"] }
    
  • smol

    agnostic-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-sys and socket2
  • macOS: Full support
  • BSD: Full support

Feature Flags

  • std (default): Standard library support
  • tokio: Tokio runtime support
  • tokio-io: Tokio I/O trait implementations
  • smol: 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.