twitter_stream_message/
user.rs

1//! Users
2
3use std::borrow::Cow;
4
5use types::{DateTime, WithheldScope};
6
7/// Represents a user on Twitter.
8///
9/// # Reference
10///
11/// 1. [Users — Twitter Developers](https://dev.twitter.com/overview/api/users)
12#[derive(Clone, Debug, Deserialize, PartialEq)]
13pub struct User<'a> {
14    /// Indicates that the user has an account with “contributor mode” enabled,
15    /// allowing for Tweets issued by the user to be co-authored
16    /// by another account. Rarely `true`.
17    pub contributors_enabled: bool,
18
19    /// The UTC datetime that the user account was created on Twitter.
20    #[serde(deserialize_with = "::util::deserialize_datetime")]
21    pub created_at: DateTime,
22
23    /// When `true`, indicates that the user has not altered
24    /// the theme or background of their user profile.
25    pub default_profile: bool,
26
27    /// When `true`, indicates that the user has not uploaded their own avatar
28    /// and a default egg avatar is used instead.
29    pub default_profile_image: bool,
30
31    /// The user-defined UTF-8 string describing their account.
32    #[serde(borrow)]
33    #[serde(default)]
34    #[serde(deserialize_with = "::util::deserialize_opt_cow_str")]
35    pub description: Option<Cow<'a, str>>,
36
37    // pub entities: Entities, // does not appear in stream messages
38
39    /// The number of tweets this user has favorited in the account’s lifetime.
40    /// British spelling used in the field name for historical reasons.
41    pub favourites_count: u64,
42
43    /// *Perspectival*. When `true`, indicates that the authenticating user has
44    /// issued a follow request to this protected user account.
45    pub follow_request_sent: Option<bool>,
46
47    // pub following: Option<bool>, // deprecated
48
49    /// The number of followers this account currently has. Under certain
50    /// conditions of duress, this field will temporarily indicate `0`.
51    pub followers_count: u64,
52
53    /// The number of users this account is following (AKA their “followings”).
54    /// Under certain conditions of duress, this field will temporarily
55    /// indicate `0`.
56    pub friends_count: u64,
57
58    /// When `true`, indicates that the user has enabled the possibility of
59    /// geotagging their Tweets. This field must be `true` for the current user
60    /// to attach geographic data when using [POST statuses / update][1].
61    ///
62    /// [1]: https://dev.twitter.com/rest/reference/post/statuses/update
63    pub geo_enabled: bool,
64
65    // does not appear in stream message
66    // pub has_extended_profile: Option<bool>,
67
68    /// The integer representation of the unique identifier for this User.
69    pub id: UserId,
70
71    // pub id_str: String,
72
73    /// When `true`, indicates that the user is a participant in Twitter’s
74    /// [translator community][1].
75    ///
76    /// [1]: http://translate.twttr.com/
77    pub is_translator: bool,
78
79    /// The [BCP 47][1] code for the user’s self-declared
80    /// user interface language. May or may not have anything to do with
81    /// the content of their Tweets.
82    ///
83    /// [1]: http://tools.ietf.org/html/bcp47
84    #[serde(borrow)]
85    pub lang: Cow<'a, str>,
86
87    /// The number of public lists that this user is a member of.
88    pub listed_count: u64,
89
90    /// The user-defined location for this account’s profile.
91    /// Not necessarily a location nor parseable. This field will occasionally
92    /// be fuzzily interpreted by the Search service.
93    #[serde(borrow)]
94    #[serde(default)]
95    #[serde(deserialize_with = "::util::deserialize_opt_cow_str")]
96    pub location: Option<Cow<'a, str>>,
97
98    /// The name of the user, as they’ve defined it. Not necessarily a person’s
99    /// name. Typically capped at 20 characters, but subject to change.
100    #[serde(borrow)]
101    pub name: Cow<'a, str>,
102
103    // pub notifications: Option<bool>, // deprecated
104
105    /// The hexadecimal color chosen by the user for their background.
106    #[serde(borrow)]
107    pub profile_background_color: Cow<'a, str>,
108
109    /// A HTTP-based URL pointing to the background image
110    /// the user has uploaded for their profile.
111    #[serde(borrow)]
112    pub profile_background_image_url: Option<Cow<'a, str>>,
113
114    /// A HTTPS-based URL pointing to the background image
115    /// the user has uploaded for their profile.
116    #[serde(borrow)]
117    pub profile_background_image_url_https: Option<Cow<'a, str>>,
118
119    /// When `true`, indicates that the user’s `profile_background_image_url`
120    /// should be tiled when displayed.
121    pub profile_background_tile: bool,
122
123    /// The HTTPS-based URL pointing to the standard web representation of
124    /// the user’s uploaded profile banner.
125    /// By adding a final path element of the URL,
126    /// you can obtain different image sizes optimized for specific displays.
127    ///
128    /// In the future, an API method will be provided to serve these URLs
129    /// so that you need not modify the original URL.
130    ///
131    /// For size variations, please see [User Profile Images and Banners][1].
132    ///
133    /// [1]: https://dev.twitter.com/basics/user-profile-images-and-banners
134    #[serde(borrow)]
135    #[serde(default)]
136    #[serde(deserialize_with = "::util::deserialize_opt_cow_str")]
137    pub profile_banner_url: Option<Cow<'a, str>>,
138
139    /// A HTTP-based URL pointing to the user’s avatar image.
140    /// See [User Profile Images and Banners][1].
141    ///
142    /// [1]: https://dev.twitter.com/basics/user-profile-images-and-banners
143    #[serde(borrow)]
144    pub profile_image_url: Cow<'a, str>,
145
146    /// A HTTPS-based URL pointing to the user’s avatar image.
147    #[serde(borrow)]
148    pub profile_image_url_https: Cow<'a, str>,
149
150    /// The hexadecimal color the user has chosen
151    /// to display links with in their Twitter UI.
152    #[serde(borrow)]
153    pub profile_link_color: Cow<'a, str>,
154
155    // pub profile_location: Option<_>, // does not appear in stream message
156
157    /// The hexadecimal color the user has chosen
158    /// to display sidebar borders with in their Twitter UI.
159    #[serde(borrow)]
160    pub profile_sidebar_border_color: Cow<'a, str>,
161
162    /// The hexadecimal color the user has chosen
163    /// to display sidebar backgrounds with in their Twitter UI.
164    #[serde(borrow)]
165    pub profile_sidebar_fill_color: Cow<'a, str>,
166
167    /// The hexadecimal color the user has chosen
168    /// to display text with in their Twitter UI.
169    #[serde(borrow)]
170    pub profile_text_color: Cow<'a, str>,
171
172    /// When `true`, indicates the user wants their uploaded background image
173    /// to be used.
174    pub profile_use_background_image: bool,
175
176    /// When `true`, indicates that this user has chosen to protect
177    /// their Tweets. See [About Public and Protected Tweets][1].
178    ///
179    /// [1]: https://support.twitter.com/articles/14016-about-public-and-protected-tweets
180    pub protected: bool,
181
182    /// The screen name, handle, or alias that this user identifies themselves
183    /// with.
184    ///
185    /// `screen_name`s are unique but subject to change.
186    /// Use `id` as a user identifier whenever possible.
187    ///
188    /// Typically a maximum of 15 characters long,
189    /// but some historical accounts may exist with longer names.
190    #[serde(borrow)]
191    pub screen_name: Cow<'a, str>,
192
193    // pub show_all_inline_media: bool, // removed
194
195    // pub status: Option<Box<Tweet>>, // does not appear in stream messages
196
197    /// The number of tweets (including retweets) issued by the user.
198    pub statuses_count: u64,
199
200    /// A string describing the Time Zone this user declares themselves within.
201    #[serde(borrow)]
202    #[serde(default)]
203    #[serde(deserialize_with = "::util::deserialize_opt_cow_str")]
204    pub time_zone: Option<Cow<'a, str>>,
205
206    /// A URL provided by the user in association with their profile.
207    #[serde(borrow)]
208    #[serde(default)]
209    #[serde(deserialize_with = "::util::deserialize_opt_cow_str")]
210    pub url: Option<Cow<'a, str>>,
211
212    /// The offset from GMT/UTC in seconds.
213    pub utc_offset: Option<i64>,
214
215    /// When `true`, indicates that the user has a verified account.
216    /// See [Verified Accounts][1].
217    ///
218    /// [1]: https://support.twitter.com/articles/119135-faqs-about-verified-accounts
219    pub verified: bool,
220
221    /// When present, indicates a textual representation of
222    /// the two-letter country codes this user is withheld from.
223    #[serde(borrow)]
224    #[serde(default)]
225    #[serde(deserialize_with = "::util::deserialize_opt_cow_str")]
226    pub withheld_in_countries: Option<Cow<'a, str>>,
227
228    /// When present, indicates whether the content being withheld is
229    /// the `Status` or a `User`.
230    #[serde(borrow)]
231    pub withheld_scope: Option<WithheldScope<'a>>,
232}
233
234/// Numerical ID of a user.
235pub type UserId = u64;