Expand description
Agnostic
agnostic is an agnostic abstraction layer for any async runtime.
If you want a light weight crate, see agnostic-lite.
§Introduction
agnostic is a comprehensive, runtime-agnostic abstraction layer for async Rust. It provides a unified API for task spawning, networking, DNS resolution, process management, and QUIC protocol support - all working seamlessly with tokio, or smol.
Looking for a lightweight option? Check out agnostic-lite for a minimal, no_std-compatible core.
§Features
- Task Management: Spawn tasks globally or locally
- Time Operations: Sleep, intervals, timeouts, and delays
- Networking: TCP listeners/streams and UDP sockets
- DNS Resolution: Multiple transports (DoH, DoT, DoQ, DoH3) with DNSSEC
- Process Management: Spawn and manage subprocesses
- QUIC Support: Quinn protocol integration
- Runtime Agnostic: Switch runtimes with a single feature flag
- Zero-Cost: Compiles to runtime-specific code
§Installation
[dependencies]
agnostic = "0.8"§Runtime Selection
Choose one runtime feature:
# For tokio
agnostic = { version = "0.8", features = ["tokio"] }
# For smol
agnostic = { version = "0.8", features = ["smol"] }§Optional Features
# Enable networking
agnostic = { version = "0.8", features = ["tokio", "net"] }
# Enable DNS resolution
agnostic = { version = "0.8", features = ["tokio", "dns"] }
# Enable DNS over HTTPS with rustls
agnostic = { version = "0.8", features = ["tokio", "dns-over-https-rustls"] }
# Enable DNS over QUIC
agnostic = { version = "0.8", features = ["tokio", "dns-over-quic"] }
# Enable DNSSEC
agnostic = { version = "0.8", features = ["tokio", "dnssec-ring"] }
# Enable process management
agnostic = { version = "0.8", features = ["tokio", "process"] }
# Enable Quinn QUIC
agnostic = { version = "0.8", features = ["tokio", "quinn"] }§Feature Flags
§Core Features
std(default): Standard library supportalloc: Allocation support
§Runtime Features (choose one)
tokio: Tokio runtime supportsmol: Smol runtime support
§Component Features
net: Network abstractions (TCP, UDP)dns: DNS resolution supportprocess: Process spawning and managementquinn: Quinn QUIC protocol supporttokio-io: Tokio I/O trait compatibility
§DNS Transport Features
dns-over-quic: DNS over QUIC (RFC 9250)dns-over-h3: DNS over HTTP/3dns-over-https-rustls: DNS over HTTPS with rustlsdns-over-rustls: DNS over TLS with rustlsdns-over-openssl: DNS over TLS with OpenSSLdns-over-native-tls: DNS over TLS with native-tlsdns-webpki-roots: Use webpki root certificatesdns-native-certs: Use OS native certificates
§DNSSEC Features
dnssec: Basic DNSSEC supportdnssec-openssl: DNSSEC with OpenSSLdnssec-ring: DNSSEC with ring crypto library
§Comparison: agnostic vs agnostic-lite
| Feature | agnostic | agnostic-lite |
|---|---|---|
| Task spawning | ✅ | ✅ |
| Time operations | ✅ | ✅ |
| Networking | ✅ | ❌ |
| DNS resolution | ✅ | ❌ |
| Process management | ✅ | ❌ |
| QUIC support | ✅ | ❌ |
no_std support | ❌ | ✅ |
| Alloc-free | ❌ | ✅ |
| No unsafe code | ❌ | ✅ |
Use agnostic-lite when:
- You need
no_stdor embedded support - You want minimal dependencies
- You only need basic async primitives
Use agnostic when:
- You need networking, DNS, or process capabilities
- You’re building standard applications
- You want a batteries-included experience
§License
agnostic 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_io as io;
Modules§
- dns
dns - Agnostic async DNS provider.
- net
net - Network related traits
- process
process - Process related traits
- quinn
quinn - Quinn related traits
- smol
smol smolruntime adapter- time
- Time related traits
- tokio
tokio tokioruntime adapter
Macros§
- cfg_
linux - Macro to conditionally compile items for
linuxsystem - cfg_
smol - Macro to conditionally compile items for
smolfeature - cfg_
tokio - Macro to conditionally compile items for
tokiofeature - cfg_
unix - Macro to conditionally compile items for
unixsystem - cfg_
windows - Macro to conditionally compile items for
windowssystem
Enums§
- After
Handle Error - Error of
AfterHandle’s output
Traits§
- After
Handle - The handle returned by the
AsyncAfterSpawnerwhen a after future is spawned. - Async
After Spawner - A spawner trait for spawning futures. Go’s
time.AfterFuncequivalent. - Async
Blocking Spawner - A spawner trait for spawning blocking.
- Async
Local Spawner - A spawner trait for spawning futures.
- Async
Spawner - A spawner trait for spawning futures.
- Join
Handle - Joinhanlde trait
- Local
Join Handle - Joinhanlde trait
- Runtime
- Runtime trait
- Runtime
Lite - Runtime trait
- Yielder
- Yielder hints the runtime to execution back