Struct UrlCleaner

Source
pub struct UrlCleaner { /* private fields */ }
Expand description

A UrlCleaner can remove tracking parameters from URLs.

This struct is relatively expensive to construct because it needs to parse the rules from JSON. It’s recommended to create one per application and reuse it.

Implementations§

Source§

impl UrlCleaner

Source

pub fn from_rules_path(path: &Path) -> Result<Self, Error>

Available on crate feature std only.

Construct a UrlCleaner with rules from a path, which will be opened and read.

§Errors

See Error

Source

pub fn from_rules_file<R: Read>(reader: R) -> Result<Self, Error>

Available on crate feature std only.

Construct a UrlCleaner with rules from a reader, most often a File

§Errors

See Error

Source

pub fn from_rules_str(rules: &str) -> Result<Self, Error>

§Errors

See Error

Source

pub fn from_embedded_rules() -> Result<Self, Error>

Construct using the JSON embedded in this library. This may be outdated, but should provide a good baseline.

§Errors

See Error

Source

pub fn strip_referral_marketing(self, value: bool) -> Self

Configure whether you want to strip referral codes and similar parameters.

While they can be considered to be tracking, they are useful on occasion. The default is false, meaning these are kept.

Source

pub fn clear_single_url_str<'a>( &self, url: &'a str, ) -> Result<Cow<'a, str>, Error>

Clean a single URL.

The argument is a string that is just a URL, with no text around.

The Cleaning may involve

    1. removing tracking parameters and/or,
    1. detecting redirections with the target url in a query parameters
§Returns

a cleaned URL

§Errors

If an error occurred. See the Error enum for possible reasons.

Source

pub fn clear_single_url<'a>(&self, url: &'a Url) -> Result<Cow<'a, Url>, Error>

Clean a single URL.

The Cleaning may involve

    1. removing tracking parameters and/or,
    1. detecting redirections with the target url in a query parameters
§Returns

a cleaned URL

§Errors

If an error occurred. See the Error enum for possible reasons.

Trait Implementations§

Source§

impl Debug for UrlCleaner

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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>,

Source§

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>,

Source§

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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,