1use std::collections::HashSet;
2use std::fmt::Debug;
3
4use serde::{Deserialize, Serialize};
5use uuid;
6use uuid::Uuid;
7use yew::Html;
8
9#[derive(Serialize, Deserialize, Debug)]
10pub enum AccessLevel {
11 PUBLIC,
12 NSFW,
13 NSFL,
14 CREDENTIALS,
15 APOCALYPTIC,
16}
17
18#[derive(Serialize, Deserialize, Debug)]
19pub struct Props {
20 uuid: Uuid,
21 votes: i64,
22 access: AccessLevel,
23}
24
25pub trait Search {
26 fn indexable_content(&self) -> String;
27 fn title(&self) -> String;
28}
29
30pub trait Relation {
31 fn parents(&self) -> HashSet<Uuid>;
32 fn children(&self) -> HashSet<Uuid>;
33 fn sources(&self) -> HashSet<Uuid>;
34}
35
36pub trait Render {
37 fn render(&self) -> Html;
38}
39
40pub trait Edit {
41 fn editor(&self) -> Html;
42}
43
44#[typetag::serde(tag = "type")]
45pub trait Note: Search + Relation + Render + Edit + Debug {
46 fn props(&self) -> &Props;
47}
48
49#[typetag::serde(tag = "type")]
50pub trait Resource: Search + Relation + Render + Debug {
51 fn props(&self) -> &Props;
52 fn url(&self) -> String;
53 fn mime(&self) -> String;
54}