[][src]Struct twitter_text::TwitterTextParseResults

pub struct TwitterTextParseResults {
    pub weighted_length: i32,
    pub permillage: i32,
    pub is_valid: bool,
    pub display_text_range: Range,
    pub valid_text_range: Range,
}

A struct that represents a parsed tweet containing the length of the tweet, its validity, display ranges etc. The name mirrors Twitter's Java implementation.

Fields

weighted_length: i32

The weighted length is the number used to determine the tweet's length for the purposes of Twitter's limit of 280. Most characters count for 2 units, while a few ranges (like ASCII and Latin-1) count for 1. See Twitter's blog post.

permillage: i32

The weighted length expressed as a number relative to a limit of 1000. This value makes it easier to implement UI like Twitter's tweet-length meter.

is_valid: bool

Whether the tweet is valid: its weighted length must be under the configured limit, it must not be empty, and it must not contain invalid characters.

display_text_range: Range

The display range expressed in UTF-16.

valid_text_range: Range

The valid display range expressed in UTF-16. After the end of the valid range, clients typically stop highlighting entities, etc.

Implementations

impl TwitterTextParseResults[src]

pub fn new(
    weighted_length: i32,
    permillage: i32,
    is_valid: bool,
    display_text_range: Range,
    valid_text_range: Range
) -> TwitterTextParseResults
[src]

A new TwitterTextParseResults struct with all fields supplied as arguments.

pub fn empty() -> TwitterTextParseResults[src]

An invalid TwitterTextParseResults struct. This function produces the return value when empty text or invalid UTF-8 is supplied to parse().

Trait Implementations

impl Clone for TwitterTextParseResults[src]

impl Copy for TwitterTextParseResults[src]

impl Debug for TwitterTextParseResults[src]

impl Eq for TwitterTextParseResults[src]

impl Hash for TwitterTextParseResults[src]

impl PartialEq<TwitterTextParseResults> for TwitterTextParseResults[src]

impl StructuralEq for TwitterTextParseResults[src]

impl StructuralPartialEq for TwitterTextParseResults[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.