pub struct HostMatcher { /* private fields */ }Expand description
A compiled set of blocked host names with subdomain-walk semantics.
Constructed once from a domain list, then shared (via Arc) across
rule evaluations per request.
Implementations§
Source§impl HostMatcher
impl HostMatcher
Sourcepub fn new(domains: impl IntoIterator<Item = String>) -> Self
pub fn new(domains: impl IntoIterator<Item = String>) -> Self
Build a matcher from an iterator of domain strings.
Each entry is lowercased and leading/trailing whitespace stripped.
Blank entries and those starting with # (comments) are silently
ignored so the caller can pass lines from a plain-text host list
directly.
Sourcepub fn is_blocked(&self, host: &str) -> bool
pub fn is_blocked(&self, host: &str) -> bool
Returns true if host is blocked.
Matching is suffix-on-dot: a.b.evil.com is blocked when evil.com
(or any ancestor up to the bare root) is in the set.
- Exact match first.
- Then strips the leftmost label repeatedly until a match or exhausted.
host is compared case-insensitively.
Trait Implementations§
Source§impl Clone for HostMatcher
impl Clone for HostMatcher
Source§fn clone(&self) -> HostMatcher
fn clone(&self) -> HostMatcher
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for HostMatcher
impl RefUnwindSafe for HostMatcher
impl Send for HostMatcher
impl Sync for HostMatcher
impl Unpin for HostMatcher
impl UnsafeUnpin for HostMatcher
impl UnwindSafe for HostMatcher
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