twapi_v2/responses/
processing_info.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Serialize, Deserialize, Debug, Clone, Default)]
4pub struct ProcessingInfo {
5    #[serde(skip_serializing_if = "Option::is_none")]
6    pub check_after_secs: Option<i64>,
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub progress_percent: Option<i64>,
9    #[serde(skip_serializing_if = "Option::is_none")]
10    pub state: Option<State>,
11    #[serde(flatten)]
12    pub extra: std::collections::HashMap<String, serde_json::Value>,
13}
14
15impl ProcessingInfo {
16    pub fn is_empty_extra(&self) -> bool {
17        let res = self.extra.is_empty();
18        if !res {
19            println!("ProcessingInfo {:?}", self.extra);
20        }
21        res
22    }
23}
24
25#[derive(Serialize, Deserialize, Debug, Clone)]
26pub enum State {
27    #[serde(rename = "succeeded")]
28    Succeeded,
29    #[serde(rename = "in_progress")]
30    InProgress,
31    #[serde(rename = "pending")]
32    Pending,
33    #[serde(rename = "failed")]
34    Failed,
35}
36
37impl std::fmt::Display for State {
38    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
39        match self {
40            Self::Succeeded => write!(f, "succeeded"),
41            Self::InProgress => write!(f, "in_progress"),
42            Self::Pending => write!(f, "pending"),
43            Self::Failed => write!(f, "failed"),
44        }
45    }
46}
47
48impl Default for State {
49    fn default() -> Self {
50        Self::Succeeded
51    }
52}