pub struct FilterChain { /* private fields */ }Expand description
Filter chain with correct include/exclude semantics.
Evaluation order:
- Exclude filters (AND): Any match → reject. Adapter must pass ALL excludes.
- Include filters (OR): Any match → accept. Adapter needs to pass ANY include. Empty includes = match all (passthrough).
§Examples
use ddns_a::network::filter::{FilterChain, KindFilter, AdapterFilter};
use ddns_a::network::{AdapterSnapshot, AdapterKind};
let chain = FilterChain::new()
.exclude(KindFilter::new([AdapterKind::Loopback]))
.include(KindFilter::new([AdapterKind::Wireless, AdapterKind::Ethernet]));
let eth = AdapterSnapshot::new("eth0", AdapterKind::Ethernet, vec![], vec![]);
let virtual_adapter = AdapterSnapshot::new("vm0", AdapterKind::Virtual, vec![], vec![]);
let loopback = AdapterSnapshot::new("lo", AdapterKind::Loopback, vec![], vec![]);
assert!(chain.matches(ð)); // Included by kind
assert!(!chain.matches(&virtual_adapter)); // Not in include kinds
assert!(!chain.matches(&loopback)); // ExcludedImplementations§
Source§impl FilterChain
impl FilterChain
Sourcepub fn include<F: AdapterFilter + 'static>(self, filter: F) -> Self
pub fn include<F: AdapterFilter + 'static>(self, filter: F) -> Self
Adds an include filter (OR semantics).
Adapters matching ANY include filter will be accepted (after passing all exclude filters).
Sourcepub fn exclude<F: AdapterFilter + 'static>(self, filter: F) -> Self
pub fn exclude<F: AdapterFilter + 'static>(self, filter: F) -> Self
Adds an exclude filter (AND semantics - must not match ANY).
Adapters matching ANY exclude filter will be rejected, regardless of include filters.
Sourcepub fn include_count(&self) -> usize
pub fn include_count(&self) -> usize
Returns the number of include filters.
Sourcepub fn exclude_count(&self) -> usize
pub fn exclude_count(&self) -> usize
Returns the number of exclude filters.
Trait Implementations§
Source§impl AdapterFilter for FilterChain
impl AdapterFilter for FilterChain
Source§fn matches(&self, adapter: &AdapterSnapshot) -> bool
fn matches(&self, adapter: &AdapterSnapshot) -> bool
Returns
true if the adapter should be included, false to filter it out.Source§impl Debug for FilterChain
impl Debug for FilterChain
Source§impl Default for FilterChain
impl Default for FilterChain
Source§fn default() -> FilterChain
fn default() -> FilterChain
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for FilterChain
impl !RefUnwindSafe for FilterChain
impl Send for FilterChain
impl Sync for FilterChain
impl Unpin for FilterChain
impl !UnwindSafe for FilterChain
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more