Skip to main content

twapi_v2/fields/
topic_fields.rs

1use serde::{Deserialize, Serialize};
2use std::collections::HashSet;
3
4#[derive(Serialize, Deserialize, Debug, Eq, Hash, PartialEq, Clone)]
5#[derive(Default)]
6pub enum TopicFields {
7    #[serde(rename = "id")]
8    #[default]
9    Id,
10    #[serde(rename = "name")]
11    Name,
12    #[serde(rename = "description")]
13    Description,
14}
15
16impl TopicFields {
17    pub fn all() -> HashSet<Self> {
18        let mut result = HashSet::new();
19        result.insert(Self::Id);
20        result.insert(Self::Name);
21        result.insert(Self::Description);
22        result
23    }
24}
25
26impl std::fmt::Display for TopicFields {
27    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
28        match self {
29            Self::Id => write!(f, "id"),
30            Self::Name => write!(f, "name"),
31            Self::Description => write!(f, "description"),
32        }
33    }
34}
35