spools/
user.rs

1use crate::{error::SpoolsError, post::Subpost, Threads};
2use serde::{Deserialize, Serialize};
3
4/// User information and statistics
5#[derive(Clone, Debug, Deserialize, Serialize)]
6pub struct User {
7    pub id: u64,
8    pub name: String,
9    pub pfp: String,
10    pub verified: bool,
11    pub bio: String,
12    pub followers: u64,
13    pub links: Vec<String>,
14    pub posts: Vec<Subpost>,
15}
16
17/// User embedded within object
18#[derive(Clone, Debug, Deserialize, Serialize)]
19pub struct Author {
20    pub username: String,
21    pub pfp: String,
22    pub verified: bool,
23}
24
25impl Author {
26    /// Convert author into its detailed counterpart
27    pub async fn to_user(&self) -> Result<User, SpoolsError> {
28        let client = Threads::new()?;
29        let user = client.fetch_user(&self.username).await?;
30
31        Ok(user)
32    }
33}