Struct publicsuffix::List

source ·
pub struct List { /* private fields */ }
Expand description

Stores the public suffix list

You can use the methods, fetch, from_url or from_path to build the list. If you are using this in a long running server it’s recommended you use either fetch or from_url to download updates at least once a week.

Implementations§

source§

impl List

source

pub fn empty() -> List

Creates an empty List without any rules

Sometimes all you want is to do syntax checks. If you don’t really care whether the domain has a known suffix or not you can just create an empty list and use that to parse domain names and email addresses.

source

pub fn from_path<P: AsRef<Path>>(path: P) -> Result<List>

Fetch the list from a local file

source

pub fn from_reader<R: Read>(reader: R) -> Result<List>

Build the list from the result of anything that implements std::io::Read

If you don’t already have your list on the filesystem but want to use your own library to fetch the list you can use this method so you don’t have to save it first.

source

pub fn from_string(string: String) -> Result<List>

Build the list from a string

The list doesn’t always have to come from a file. You can maintain your own list, say in a DBMS. You can then pull it at runtime and build the list from the resulting String.

source

pub fn from_str(string: &str) -> Result<List>

Build the list from a str

The list doesn’t always have to come from a file. You can maintain your own list, say in a DBMS. You can then pull it at runtime and build the list from the resulting str.

source

pub fn icann(&self) -> Vec<&str>

Gets a list of all ICANN domain suffices

source

pub fn private(&self) -> Vec<&str>

Gets a list of all private domain suffices

source

pub fn all(&self) -> Vec<&str>

Gets a list of all domain suffices

source

pub fn parse_domain(&self, domain: &str) -> Result<Domain>

Parses a domain using the list

source

pub fn parse_host(&self, host: &str) -> Result<Host>

Parses a host using the list

A host, for the purposes of this library, is either an IP address or a domain name.

source

pub fn parse_url<U: IntoUrl>(&self, url: U) -> Result<Host>

Extracts Host from a URL

source

pub fn parse_email(&self, address: &str) -> Result<Host>

Extracts Host from an email address

This method can also be used, simply to validate an email address. If it returns an error, the email address is not valid.

source

pub fn parse_str(&self, string: &str) -> Result<Host>

Parses any arbitrary string

Effectively this means that the string is either a URL, an email address or a host.

source

pub fn parse_dns_name(&self, name: &str) -> Result<DnsName>

Parses any arbitrary string that can be used as a key in a DNS database

Trait Implementations§

source§

impl Debug for List

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for List

§

impl RefUnwindSafe for List

§

impl Send for List

§

impl Sync for List

§

impl Unpin for List

§

impl UnwindSafe for List

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.