Configuration

Struct Configuration 

Source
pub struct Configuration {
    pub dm_text_character_limit: i32,
    pub photo_sizes: MediaSizes,
    pub short_url_length: i32,
    pub short_url_length_https: i32,
    pub non_username_paths: Vec<String>,
}
Expand description

Represents a service configuration from Twitter.

The values returned in this struct are various pieces of information that, while they don’t change often, have the opportunity to change over time and affect things like character counting or whether to route a twitter.com URL to a user lookup or a browser.

While tweets themselves still have a fixed 280-character limit, direct messages have had their text limit expanded to 10,000 characters, and that length is communicated here, in dm_text_character_limit.

For photo_sizes, note that if your image is smaller than the dimensions given for a particular size, that size variant will simply return your source image as-is. If either dimension is larger than its corresponding dimension here, it will be scaled according to the included resize property. In practice this usually means thumb will crop to its dimensions, and each other variant will resize down, keeping its aspect ratio.

For best ways to handle the short_url_length fields, see Twitter’s documentation on t.co URLs. In short, every URL Twitter detects in a new tweet or direct message gets a new t.co URL created for it, which replaces the original URL in the given text. This affects character counts for these fields, so if your app is counting characters and detects a URL for these fields, treat the whole URL as if it were as long as the number of characters given in this struct.

Finally, loading non_username_paths allows you to handle twitter.com/[name] links as if they were a user mention, while still keeping site-level links working properly.

Fields§

§dm_text_character_limit: i32

The character limit in direct messages.

§photo_sizes: MediaSizes

The maximum dimensions for each photo size variant.

§short_url_length: i32

The maximum length for a t.co URL when given a URL with protocol http.

§short_url_length_https: i32

The maximum length for a t.co URL when given a URL with protocol https.

§non_username_paths: Vec<String>

A list of URL slugs that are not valid usernames when in a URL like twitter.com/[slug].

Trait Implementations§

Source§

impl Debug for Configuration

Source§

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

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

impl<'de> Deserialize<'de> for Configuration

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,