twapi_v2/fields/
topic_fields.rs

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