Skip to main content

twapi_v2/responses/
user_entities.rs

1use crate::responses::{description::Description, user_url::UserUrl};
2use serde::{Deserialize, Serialize};
3
4#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq)]
5pub struct UserEntities {
6    #[serde(skip_serializing_if = "Option::is_none")]
7    pub url: Option<UserUrl>,
8    #[serde(skip_serializing_if = "Option::is_none")]
9    pub description: Option<Description>,
10    #[serde(flatten)]
11    pub extra: std::collections::HashMap<String, serde_json::Value>,
12}
13
14impl UserEntities {
15    pub fn is_empty_extra(&self) -> bool {
16        let res = self.extra.is_empty()
17            && self
18                .url
19                .as_ref()
20                .map(|it| it.is_empty_extra())
21                .unwrap_or(true)
22            && self
23                .description
24                .as_ref()
25                .map(|it| it.is_empty_extra())
26                .unwrap_or(true);
27        if !res {
28            println!("UserEntities {:?}", self.extra);
29        }
30        res
31    }
32}