twitter_api_v1/objects/
user.rs

1use serde::{Deserialize, Serialize};
2use twitter_api_v2::objects::User as V2User;
3
4//
5#[derive(Deserialize, Serialize, Debug, Clone)]
6pub struct User {
7    pub id: u64,
8    pub id_str: String,
9    pub screen_name: String,
10    pub profile_banner_url: Option<String>,
11    pub profile_image_url_https: String,
12    pub default_profile_image: bool,
13}
14
15//
16impl TryFrom<V2User> for User {
17    type Error = String;
18    fn try_from(value: V2User) -> Result<Self, Self::Error> {
19        Ok(Self {
20            id: value.id.ok_or("id missing")?,
21            id_str: value.id.ok_or("id missing")?.to_string(),
22            screen_name: value.username.ok_or("username missing")?,
23            profile_banner_url: None,
24            profile_image_url_https: value.profile_image_url.ok_or("profile_image_url missing")?,
25            default_profile_image: false,
26        })
27    }
28}