Skip to main content

threads_rs/types/
user.rs

1use serde::{Deserialize, Serialize};
2
3use super::common::RecentSearch;
4use super::ids::UserId;
5
6/// A Threads user profile with app-scoped data.
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct User {
9    /// User ID.
10    pub id: UserId,
11    /// Username.
12    pub username: String,
13    /// Display name.
14    #[serde(default, skip_serializing_if = "Option::is_none")]
15    pub name: Option<String>,
16    /// Profile picture URL.
17    #[serde(default, skip_serializing_if = "Option::is_none")]
18    pub threads_profile_picture_url: Option<String>,
19    /// Biography.
20    #[serde(default, skip_serializing_if = "Option::is_none")]
21    pub threads_biography: Option<String>,
22    /// Website URL.
23    #[serde(default, skip_serializing_if = "Option::is_none")]
24    pub website: Option<String>,
25    /// Followers count.
26    #[serde(default)]
27    pub followers_count: i64,
28    /// Total media count.
29    #[serde(default)]
30    pub media_count: i64,
31    /// Whether the user is verified.
32    #[serde(default)]
33    pub is_verified: bool,
34    /// Whether the user is eligible for geo-gating.
35    #[serde(default)]
36    pub is_eligible_for_geo_gating: bool,
37    /// Recently searched keywords.
38    #[serde(default, skip_serializing_if = "Option::is_none")]
39    pub recently_searched_keywords: Option<Vec<RecentSearch>>,
40}
41
42/// A public Threads user profile (via `threads_profile_discovery` scope).
43#[derive(Debug, Clone, Serialize, Deserialize)]
44pub struct PublicUser {
45    /// Username.
46    pub username: String,
47    /// Display name (may be absent on some profiles).
48    #[serde(default, skip_serializing_if = "Option::is_none")]
49    pub name: Option<String>,
50    /// Profile picture URL.
51    #[serde(default, skip_serializing_if = "Option::is_none")]
52    pub profile_picture_url: Option<String>,
53    /// User biography.
54    #[serde(default, skip_serializing_if = "Option::is_none")]
55    pub biography: Option<String>,
56    /// Whether the user is verified.
57    #[serde(default)]
58    pub is_verified: bool,
59    /// Follower count.
60    #[serde(default)]
61    pub follower_count: i64,
62    /// Total likes count.
63    #[serde(default)]
64    pub likes_count: i64,
65    /// Total quotes count.
66    #[serde(default)]
67    pub quotes_count: i64,
68    /// Total replies count.
69    #[serde(default)]
70    pub replies_count: i64,
71    /// Total reposts count.
72    #[serde(default)]
73    pub reposts_count: i64,
74    /// Total views count.
75    #[serde(default)]
76    pub views_count: i64,
77}