pub struct MediaEntity {
    pub display_url: String,
    pub expanded_url: String,
    pub id: u64,
    pub range: (usize, usize),
    pub media_url: String,
    pub media_url_https: String,
    pub sizes: MediaSizes,
    pub source_status_id: Option<u64>,
    pub media_type: MediaType,
    pub url: String,
    pub video_info: Option<VideoInfo>,
    pub ext_alt_text: Option<String>,
}
Expand description

Represents a piece of media attached to a tweet.

The information in this struct is subtly different depending on what media is being referenced, and which entity container is holding this instance. For videos and GIFs, the media_url and media_url_https fields each link to a thumbnail image of the media, typically of the first frame. The real video information can be found on the video_info field, including various encodings if available.

Image links available in media_url and media_url_https can be obtained in different sizes by appending a colon and one of the available sizes in the MediaSizes struct. For example, the cropped thumbnail can be viewed by appending :thumb to the end of the URL, and the full-size image can be viewed by appending :large.

Fields§

§display_url: String

A shortened URL to display to clients.

§expanded_url: String

An expanded version of display_url; links to the media display page.

§id: u64

A numeric ID for the media.

§range: (usize, usize)

The byte offsets where the media URL is located. The first index is the location of the first character of the URL; the second is the location of the first character following the URL.

§media_url: String

A URL pointing directly to the media file. Uses HTTP as the protocol.

For videos and GIFs, this link will be to a thumbnail of the media, and the real video link will be contained in video_info.

§media_url_https: String

A URL pointing directly to the media file. Uses HTTPS as the protocol.

For videos and GIFs, this link will be to a thumbnail of the media, and the real video link will be contained in video_info.

§sizes: MediaSizes

Various sizes available for the media file.

§source_status_id: Option<u64>

For tweets containing media that was originally associated with a different tweet, this contains the ID of the original tweet.

§media_type: MediaType

The type of media being represented.

§url: String

The t.co link from the original text.

§video_info: Option<VideoInfo>

For media entities corresponding to videos, this contains extra information about the linked video.

§ext_alt_text: Option<String>

Media alt text, if present.

Trait Implementations§

source§

impl Clone for MediaEntity

source§

fn clone(&self) -> MediaEntity

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for MediaEntity

source§

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

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

impl<'de> Deserialize<'de> for MediaEntity

source§

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

Deserialize this value from the given Serde deserializer. Read more
source§

impl Serialize for MediaEntity

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where
    __S: Serializer,

Serialize this value into the given Serde serializer. 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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · 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 Twhere
    U: From<T>,

const: unstable · 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<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere
    T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere
    U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · 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.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere
    V: MultiLane<T>,

§

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 Twhere
    T: for<'de> Deserialize<'de>,