Function psl::init
[−]
[src]
pub fn init<U, D>(url: U, every: D) -> Result<()> where
U: IntoUrl,
D: Into<Option<Duration>>,
Initialise the list
Call from your main
or run
function. It fetches the list from url
using a certain interval.
Example
extern crate psl; extern crate publicsuffix; use publicsuffix::LIST_URL; use std::time::Duration; fn main() { // Update the list every week psl::init(LIST_URL, None).unwrap(); // Or update every 2 weeks psl::init(LIST_URL, Duration::from_secs(60 * 60 * 24 * 7 * 2)).unwrap(); }
If it fails to fetch the list for the first time it will return an error.
After it successfully fetches the list for the first time it will try to download
an update at every
interval retrying every 5 minutes if it fails.
If you are using this in a long running server, I highly recommend you set up a logger
using set_logger
so you will know if updates start failing at some point in future.