auraxis/api/collections/
mod.rs1use crate::api::collections::character::CharacterCollection;
2use std::fmt::{Display, Formatter};
3
4use async_trait::async_trait;
5
6mod character;
7
8#[async_trait]
9pub trait Collection {
10 fn name() -> &'static str;
11}
12
13#[derive(Debug, Copy, Clone)]
14pub enum CensusCollection {
15 Character,
16}
17
18impl CensusCollection {
19 pub fn name(&self) -> &str {
20 match self {
21 CensusCollection::Character => CharacterCollection::name(),
22 }
23 }
24}
25
26impl From<CensusCollection> for String {
27 fn from(val: CensusCollection) -> Self {
28 val.name().to_string()
29 }
30}
31
32impl Display for CensusCollection {
33 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
34 write!(f, "{}", self.name())
35 }
36}