Skip to main content

Extractor

Struct Extractor 

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

An Extract implementation that does no validation (length checks, validity, etc).

Implementations§

Source§

impl Extractor

Source

pub fn new() -> Extractor

Create a new extractor that extracts URLs without a protocol.

Source

pub fn extract_urls(&self, s: &str) -> Vec<String>

Extract a vector of URLs as String objects.

Trait Implementations§

Source§

impl<'a> Extract<'a> for Extractor

Source§

type T = Vec<Entity<'a>>

Extractor returns a vector of entities with no validation data.

Source§

type Mention = Option<Entity<'a>>

Extractor returns a single mention entity with no validation data.

Source§

fn get_extract_url_without_protocol(&self) -> bool

Get whether the extractor will detect URLs without schemes, such as “example.com”.
Source§

fn set_extract_url_without_protocol( &mut self, extract_url_without_protocol: bool, )

Set whether the extractor will detect URLs without schemes, such as “example.com”.
Source§

fn extract(&self, s: &'a str, r_match: fn(Rule) -> bool) -> Vec<Entity<'a>>

Extract entities from the source text that match rules allowed by r_match.
Source§

fn create_result( &self, s: &'a str, count: usize, scanned: &mut Vec<UnprocessedEntity<'a>>, ) -> Vec<Entity<'a>>

Create the result type. The concrete type varies by implementation.
Source§

fn extract_reply_username(&self, s: &'a str) -> Option<Entity<'a>>

Create the mention result type. The concrete type varies by implementation.
Source§

fn mention_result( &self, s: &'a str, entity: Option<Pair<'a, Rule>>, ) -> Option<Entity<'a>>

Create a mention result type from a pest::Pair.
Source§

fn empty_result(&self) -> Vec<Entity<'a>>

Returns an empty result. Used when the input is invalid.
Source§

fn extract_impl(&self, s: &'a str, r_match: fn(Rule) -> bool) -> Self::T

Source§

fn extract_urls_with_indices(&self, s: &'a str) -> Self::T

Extract all URLs from the text, subject to value returned by Extract::get_extract_url_without_protocol.
Source§

fn extract_hashtags(&self, s: &'a str) -> Self::T

Extract all Hashtags from the text
Source§

fn extract_cashtags(&self, s: &'a str) -> Self::T

Extract all Cashtags from the text
Source§

fn extract_mentioned_screennames(&self, s: &'a str) -> Self::T

Extract all usernames from the text. The same as Extract::extract_mentioned_screennames_with_indices, but included for compatibility.
Source§

fn extract_mentioned_screennames_with_indices(&self, s: &'a str) -> Self::T

Extract all usernames from the text.
Source§

fn extract_mentions_or_lists_with_indices(&self, s: &'a str) -> Self::T

Extract all usernames and lists from the text.
Source§

fn extract_reply_username_impl(&self, s: &'a str) -> Self::Mention

Extract a “reply”–a username that appears at the beginning of a tweet.
Source§

fn extract_entities_with_indices(&self, s: &'a str) -> Self::T

Extract all entities from the text (Usernames, Lists, Hashtags, Cashtags, and URLs).
Source§

fn extract_scan(&self, s: &'a str) -> Self::T

Parse the text without extracting any entities.
Source§

fn entity_from_pair( &self, ue: UnprocessedEntity<'a>, start: i32, end: i32, ) -> Option<Entity<'a>>

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.