pinterest_api/parameter/
metric_type.rs1use serde::{Deserialize, Serialize};
2use std::fmt;
3
4#[derive(Debug, Clone)]
5pub enum MetricTypes {
6 Standard(Vec<StandardMetricType>),
7 Video(Vec<VideoMetricType>),
8}
9
10impl Default for MetricTypes {
11 fn default() -> Self {
12 Self::Standard(vec![])
13 }
14}
15
16impl std::fmt::Display for MetricTypes {
17 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
18 let result = match self {
19 Self::Standard(metric_types) => metric_types
20 .iter()
21 .map(|metric_type| metric_type.to_string())
22 .collect::<Vec<String>>()
23 .join(","),
24 Self::Video(metric_types) => metric_types
25 .iter()
26 .map(|metric_type| metric_type.to_string())
27 .collect::<Vec<String>>()
28 .join(","),
29 };
30 write!(f, "{}", result)
31 }
32}
33
34#[derive(Serialize, Deserialize, Debug, Clone)]
35#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
36pub enum StandardMetricType {
37 Impression,
38 OutboundClick,
39 PinClick,
40 Save,
41 SaveRate,
42 TotalComments,
43 TotalReactions,
44 UserFollow,
45 ProfileVisit,
46}
47
48impl fmt::Display for StandardMetricType {
49 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
50 match self {
51 Self::Impression => write!(f, "IMPRESSION"),
52 Self::OutboundClick => write!(f, "OUTBOUND_CLICK"),
53 Self::PinClick => write!(f, "PIN_CLICK"),
54 Self::Save => write!(f, "SAVE"),
55 Self::SaveRate => write!(f, "SAVE_RATE"),
56 Self::TotalComments => write!(f, "TOTAL_COMMENTS"),
57 Self::TotalReactions => write!(f, "TOTAL_REACTIONS"),
58 Self::UserFollow => write!(f, "USER_FOLLOW"),
59 Self::ProfileVisit => write!(f, "PROFILE_VISIT"),
60 }
61 }
62}
63
64impl Default for StandardMetricType {
65 fn default() -> Self {
66 Self::Impression
67 }
68}
69
70#[derive(Serialize, Deserialize, Debug, Clone)]
71#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
72pub enum VideoMetricType {
73 Impression,
74 OutboundClick,
75 PinClick,
76 Save,
77 SaveRate,
78 VideoMrcView,
79 Video10sView,
80 Quartile95PercentView,
81 VideoV50WatchTime,
82 VideoStart,
83 VideoAvgWatchTime,
84 TotalComments,
85 TotalReactions,
86}
87
88impl fmt::Display for VideoMetricType {
89 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
90 match self {
91 Self::Impression => write!(f, "IMPRESSION"),
92 Self::OutboundClick => write!(f, "OUTBOUND_CLICK"),
93 Self::PinClick => write!(f, "PIN_CLICK"),
94 Self::Save => write!(f, "SAVE"),
95 Self::SaveRate => write!(f, "SAVE_RATE"),
96 Self::VideoMrcView => write!(f, "VIDEO_MRC_VIEW"),
97 Self::Video10sView => write!(f, "VIDEO_10S_VIEW"),
98 Self::Quartile95PercentView => write!(f, "QUARTILE_95_PERCENT_VIEW"),
99 Self::VideoV50WatchTime => write!(f, "VIDEO_V50_WATCH_TIME"),
100 Self::VideoStart => write!(f, "VIDEO_START"),
101 Self::VideoAvgWatchTime => write!(f, "VIDEO_AVG_WATCH_TIME"),
102 Self::TotalComments => write!(f, "TOTAL_COMMENTS"),
103 Self::TotalReactions => write!(f, "TOTAL_REACTIONS"),
104 }
105 }
106}
107
108impl Default for VideoMetricType {
109 fn default() -> Self {
110 Self::Impression
111 }
112}