Skip to main content

x_rs/
types.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize)]
4pub struct User {
5    pub id: String,
6    pub username: String,
7    pub name: Option<String>,
8    pub description: Option<String>,
9    pub profile_image_url: Option<String>,
10    pub profile_banner_url: Option<String>,
11    pub is_private: bool,
12    pub is_verified: bool,
13    pub is_blue_verified: bool,
14    pub follower_count: u64,
15    pub following_count: u64,
16    pub tweet_count: u64,
17    pub listed_count: u64,
18    pub created_at: Option<String>,
19    pub location: Option<String>,
20    pub url: Option<String>,
21    pub pinned_tweet_id: Option<String>,
22}
23
24#[derive(Debug, Clone, Serialize, Deserialize)]
25pub struct Tweet {
26    pub id: String,
27    pub text: String,
28    pub author_id: String,
29    pub author: Option<TweetAuthor>,
30    pub created_at: Option<String>,
31    pub conversation_id: Option<String>,
32    pub lang: Option<String>,
33    pub like_count: u64,
34    pub retweet_count: u64,
35    pub reply_count: u64,
36    pub quote_count: u64,
37    pub view_count: Option<u64>,
38    pub bookmark_count: Option<u64>,
39    pub is_retweet: bool,
40    pub is_quote: bool,
41    pub is_reply: bool,
42    pub in_reply_to_user_id: Option<String>,
43    pub in_reply_to_tweet_id: Option<String>,
44    pub quoted_tweet: Option<Box<Tweet>>,
45    pub retweeted_tweet: Option<Box<Tweet>>,
46    pub media: Vec<Media>,
47    pub urls: Vec<TweetUrl>,
48    pub hashtags: Vec<String>,
49    pub mentions: Vec<TweetMention>,
50}
51
52#[derive(Debug, Clone, Serialize, Deserialize)]
53pub struct TweetDetail {
54    pub tweet: Tweet,
55    pub thread: Vec<Tweet>,
56}
57
58#[derive(Debug, Clone, Serialize, Deserialize)]
59pub struct TweetAuthor {
60    pub id: String,
61    pub username: String,
62    pub name: Option<String>,
63    pub profile_image_url: Option<String>,
64    pub is_verified: bool,
65    pub is_blue_verified: bool,
66}
67
68#[derive(Debug, Clone, Serialize, Deserialize)]
69pub struct Media {
70    pub id: String,
71    pub media_type: MediaType,
72    pub url: Option<String>,
73    pub preview_url: Option<String>,
74    pub width: Option<u32>,
75    pub height: Option<u32>,
76    pub duration_ms: Option<u64>,
77    pub alt_text: Option<String>,
78}
79
80#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
81#[serde(rename_all = "snake_case")]
82pub enum MediaType {
83    Photo,
84    Video,
85    Gif,
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
89pub struct TweetUrl {
90    pub url: String,
91    pub expanded_url: String,
92    pub display_url: String,
93}
94
95#[derive(Debug, Clone, Serialize, Deserialize)]
96pub struct TweetMention {
97    pub id: String,
98    pub username: String,
99}