twapi_v2/responses/
withheld.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq)]
4pub struct Withheld {
5 #[serde(skip_serializing_if = "Option::is_none")]
6 pub copyright: Option<bool>,
7 #[serde(skip_serializing_if = "Option::is_none")]
8 pub country_codes: Option<Vec<String>>,
9 #[serde(skip_serializing_if = "Option::is_none")]
10 pub scope: Option<Scope>,
11 #[serde(flatten)]
12 pub extra: std::collections::HashMap<String, serde_json::Value>,
13}
14
15impl Withheld {
16 pub fn is_empty_extra(&self) -> bool {
17 let res = self.extra.is_empty();
18 if !res {
19 println!("Withheld {:?}", self.extra);
20 }
21 res
22 }
23}
24
25#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default)]
26pub enum Scope {
27 #[serde(rename = "tweet")]
28 #[default]
29 Tweet,
30 #[serde(rename = "user")]
31 User,
32}
33
34impl std::fmt::Display for Scope {
35 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
36 match self {
37 Self::Tweet => write!(f, "tweet"),
38 Self::User => write!(f, "user"),
39 }
40 }
41}