4 releases (2 breaking)
new 0.3.0 | Mar 23, 2025 |
---|---|
0.2.2 | Dec 1, 2024 |
0.2.1 |
|
0.1.1 | Oct 27, 2024 |
#1882 in Network programming
29 downloads per month
Used in 4 crates
(via fcnet)
13KB
185 lines
nftables-async
An async version of the helper to run nftables in the nftables
crate. Simply add both nftables-async
and nftables
to your crate, then use the nftables_async::apply_ruleset
or nftables_async::get_current_ruleset
to perform manipulations. Everything is compatible with the sync helper, even the error types, the functions, however, return "true" async futures.
To provide the asynchronous I/O, an implementation of the Process
trait in the crate is needed. Two implementations are provided built-in behind feature gates:
TokioProcess
using the Tokio stack, enabled viatokio-process
featureAsyncProcess
using theasync-process
crate (Smol stack), enabled viaasync-process
feature.
Why not the async helpers in nftables >0.6?
nftables 0.6.0
introduced tokio
and async-process
features that are mostly equivalent to this crate, however, these have some disadvantages that make nftables-async
still relevant:
- The support in
nftables
is not implemented via a trait (likenftables_async::Process
), meaning third-party extensions for async platforms other than Tokio or theasync-*
stack are not easily possible. - The two features are mutually exclusive, making it impossible to compile an
nftables
that has both enabled. This breaks the use-case offcnet
, that needs both when enabling multiple runtime features, and is generally inconvenient.
Dependencies
~2–14MB
~180K SLoC