-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathevents.rs
More file actions
51 lines (45 loc) · 1.28 KB
/
events.rs
File metadata and controls
51 lines (45 loc) · 1.28 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
46
47
48
49
50
51
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use std::fmt;
use crate::components::cards_list::CardsListItem;
use crate::types::person::Person;
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Hash, Ord, PartialOrd, Copy)]
#[serde(rename_all = "snake_case")]
pub enum EventTags {
Workshop,
Meetup,
Webinar,
InPerson,
Hackathon,
}
impl fmt::Display for EventTags {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let s = match self {
EventTags::Workshop => "Workshop",
EventTags::Meetup => "Meetup",
EventTags::Webinar => "Webinar",
EventTags::InPerson => "In-Person",
EventTags::Hackathon => "Hackathon",
};
write!(f, "{}", s)
}
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
pub struct CommunityEvent {
pub banner: String,
pub name: String,
pub description: String,
pub speakers: Vec<Person>,
pub event_link: String,
pub date: DateTime<Utc>,
pub tags: Vec<EventTags>,
}
impl CardsListItem for CommunityEvent {
type Tag = EventTags;
fn get_key(&self) -> String {
format!("event-{}-{}", self.name, self.banner)
}
fn get_tags(&self) -> &Vec<EventTags> {
&self.tags
}
}