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