agnostic-net

Crates.ioagnostic-net
lib.rsagnostic-net
version0.3.0
created_at2025-01-27 03:15:34.157329+00
updated_at2025-11-04 03:05:08.024947+00
descriptionAgnostic abstraction layer of `std::net` for any async runtime.
homepagehttps://github.com/al8n/agnostic
repositoryhttps://github.com/al8n/agnostic
max_upload_size
id1531957
size148,353
Al Liu (al8n)

documentation

README

Agnostic Network

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

github LoC Build codecov

docs.rs crates.io crates.io license

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.

Commit count: 173

cargo fmt