Trait adblock::url_parser::ResolvesDomain

source ·
pub trait ResolvesDomain: Send + Sync {
    // Required method
    fn get_host_domain(&self, host: &str) -> (usize, usize);
}
Expand description

Required trait for any domain resolution implementation used with this crate.

Required Methods§

source

fn get_host_domain(&self, host: &str) -> (usize, usize)

Return the start and end indices of the domain (eTLD+1) of the given hostname.

If there isn’t a valid domain, (0, host.len()) should be returned.

let host = "api.m.example.com";
let (start, end) = resolver.get_host_domain(host);
assert_eq!(&host[start..end], "example.com");

let host = "a.b.co.uk";
let (start, end) = resolver.get_host_domain(host);
assert_eq!(&host[start..end], "b.co.uk");

Implementors§