Struct linkify::LinkFinder

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

A configured link finder.

Implementations§

source§

impl LinkFinder

source

pub fn new() -> LinkFinder

Create a new link finder with the default options for finding all kinds of links.

If you only want to find a certain kind of links, use the kinds method.

source

pub fn email_domain_must_have_dot(&mut self, value: bool) -> &mut LinkFinder

Require the domain parts of email addresses to have at least one dot. Use false to also find addresses such as root@localhost.

source

pub fn url_must_have_scheme( &mut self, url_must_have_scheme: bool ) -> &mut LinkFinder

Set whether URLs must have a scheme, defaults to true.

By default only URLs having a scheme defined are found. By setting this to false you make the scheme of URLs optional, to also find URLs like example.org. For some URLs the used scheme is important, and making the scheme optional may lead to finding a lot of false positive URLs.

source

pub fn url_can_be_iri(&mut self, url_can_be_iri: bool) -> &mut LinkFinder

Sets whether URLs can be IRI according to RFC-3987. The default is true. Setting it to false means domains can contain ASCII characters only.

source

pub fn kinds(&mut self, kinds: &[LinkKind]) -> &mut LinkFinder

Restrict the kinds of links that should be found to the specified ones.

Find links in the specified input text.

Returns an Iterator which only scans when next is called (lazy).

source

pub fn spans<'t>(&self, text: &'t str) -> Spans<'t>

Iterate over spans in the specified input text.

A span represents a substring of the input text, which can either be a link, or plain text.

Returns an Iterator which only scans when next is called (lazy).

The spans that are returned by the Iterator are consecutive, and when combined represent the input text in its entirety.

Trait Implementations§

source§

impl Debug for LinkFinder

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for LinkFinder

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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.