-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy patharticles.rs
More file actions
45 lines (39 loc) · 1.15 KB
/
articles.rs
File metadata and controls
45 lines (39 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use crate::components::cards_list::CardsListItem;
use crate::types::person::Person;
use std::fmt;
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Hash, Ord, PartialOrd, Copy)]
#[serde(rename_all = "snake_case")]
pub enum ArticleTags {
Technical,
DeveloperStory,
}
impl fmt::Display for ArticleTags {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let s = match self {
ArticleTags::Technical => "Technical",
ArticleTags::DeveloperStory => "Developer Story",
};
write!(f, "{}", s)
}
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
pub struct CommunityArticle {
pub banner: String,
pub name: String,
pub description: String,
pub authors: Vec<Person>,
pub article_link: String,
pub date: DateTime<Utc>,
pub tags: Vec<ArticleTags>,
}
impl CardsListItem for CommunityArticle {
type Tag = ArticleTags;
fn get_key(&self) -> String {
format!("event-{}-{}", self.name, self.banner)
}
fn get_tags(&self) -> &Vec<ArticleTags> {
&self.tags
}
}