pub struct NftablesConfig { /* private fields */ }Expand description
A complete declarative nftables ruleset. Construct via
Self::new + fluent setters; commit via the diff/apply
flow on Connection<Nftables>.
See the module-level docs for usage.
Implementations§
Source§impl NftablesConfig
impl NftablesConfig
Sourcepub async fn diff(&self, conn: &Connection<Nftables>) -> Result<NftablesDiff>
pub async fn diff(&self, conn: &Connection<Nftables>) -> Result<NftablesDiff>
Compute the diff between this declared config and the kernel’s current state.
§Rule-identity caveat (0.16)
Rules without a handle_key are always added — there’s
no diff identity for them. Rules with a handle_key are
matched against kernel rules by the key (the kernel doesn’t
know our keys; we just emit the same set as we declared,
and any extras are deleted on apply). Full byte-canonical
diff is a follow-up; this gets the user a working
declarative apply now with explicit churn-vs-correctness
trade-off.
Source§impl NftablesConfig
impl NftablesConfig
Sourcepub fn new() -> Self
pub fn new() -> Self
Construct an empty config. Add tables via Self::table.
Sourcepub fn table<F>(self, name: impl Into<String>, family: Family, f: F) -> Selfwhere
F: FnOnce(DeclaredTableBuilder) -> DeclaredTableBuilder,
pub fn table<F>(self, name: impl Into<String>, family: Family, f: F) -> Selfwhere
F: FnOnce(DeclaredTableBuilder) -> DeclaredTableBuilder,
Declare a table. The closure receives a
DeclaredTableBuilder that lets you nest chains, rules,
and flowtables inside the table — matching the visual
hierarchy of nft list ruleset.
Sourcepub fn tables(&self) -> &[DeclaredTable]
pub fn tables(&self) -> &[DeclaredTable]
All declared tables. Borrowed view.
Trait Implementations§
Source§impl Clone for NftablesConfig
impl Clone for NftablesConfig
Source§fn clone(&self) -> NftablesConfig
fn clone(&self) -> NftablesConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more