Skip to main content

activities/object/
mod.rs

1use crate::link::{Link, Mime};
2pub use article::Article;
3pub use document::Document;
4pub use document::DocumentType;
5use serde::{Deserialize, Serialize};
6
7use std::time::Duration;
8pub use video::Video;
9
10mod article;
11// mod audio;
12mod document;
13// mod event;
14// mod image;
15// mod note;
16// mod page;
17// mod place;
18// mod profile;
19// mod relationship;
20// mod tombstone;
21mod video;
22
23#[typetag::serde(tag = "type")]
24pub trait TypedObjectType: ObjectType {}
25
26pub trait ObjectType {
27    fn attachment(&self) {}
28    fn attributed_to(&self) {}
29    fn audience(&self) {}
30    fn content(&self) -> Option<&String> {
31        None
32    }
33    fn context(&self) {}
34    fn name(&self) -> Option<&String> {
35        None
36    }
37    fn end_time(&self) {}
38    fn generator(&self) {}
39    fn icon(&self) {}
40    fn image(&self) {}
41    fn in_reply_to(&self) {}
42    fn location(&self) {}
43    fn preview(&self) {}
44    fn published(&self) {}
45    fn summary(&self) {}
46    fn tag(&self) {}
47    fn updated(&self) {}
48    fn url(&self) -> Option<&Link> {
49        None
50    }
51    fn to(&self) {}
52    fn bto(&self) {}
53    fn cc(&self) {}
54    fn bcc(&self) {}
55    fn media_type(&self) -> Option<Mime> {
56        None
57    }
58    fn duration(&self) -> Option<Duration> {
59        None
60    }
61}
62
63#[derive(Deserialize, Serialize)]
64pub enum LinkOrObject {
65    Link(Link),
66    Object(Box<dyn TypedObjectType>),
67}
68
69#[derive(Deserialize, Serialize)]
70pub enum LinkOrList {
71    Link(Link),
72    List(Vec<Box<dyn TypedObjectType>>),
73}
74
75#[derive(Deserialize, Serialize)]
76pub enum LinkObjectOrList {
77    Link(Link),
78    Object(Box<dyn TypedObjectType>),
79    List(Vec<Box<dyn TypedObjectType>>),
80}