rustpub/simple/
core.rs

1use serde::{Deserialize, Serialize};
2
3use crate::simple::properties as props;
4use crate::simple::properties::*;
5
6use rustpub_macro::activitypub_complex;
7
8#[derive(Clone, Debug, Deserialize, Serialize)]
9struct CoreKind {
10    #[serde(rename = "type")]
11    kind: Kind,
12}
13
14pub fn core_kind(input: &str) -> std::result::Result<Kind, serde_json::Error> {
15    let core_kind: CoreKind = serde_json::from_str(input)?;
16    Ok(core_kind.kind)
17}
18
19activitypub_complex! {
20    base_traits {
21        ObjectBaseTrait,
22        LinkBaseTrait,
23    }
24    group_traits {
25        ObjectTrait: ObjectBaseTrait,
26        LinkTrait: LinkBaseTrait,
27    }
28    ObjectTrait {
29        Object {
30            id: Id,
31            kind rename "type": Kind,
32            attachment: Attachment,
33            attributed_to: AttributedTo,
34            audience: Audience,
35            content alias "contentMap": Content,
36            context rename "@context": Context,
37            name alias "nameMap": Name,
38            end_time: EndTime,
39            generator: Generator,
40            icon: Icon,
41            image: props::Image,
42            in_reply_to: InReplyTo,
43            location: Location,
44            preview: Preview,
45            published: Published,
46            replies: Replies,
47            start_time: StartTime,
48            summary alias "summaryMap": Summary,
49            tag: Tag,
50            updated: Updated,
51            url: Url,
52            to: To,
53            bto: BTo,
54            cc: CC,
55            bcc: BCC,
56            media_type: MediaType,
57            duration: Duration,
58            one_of: OneOf,
59            any_of: AnyOf,
60            closed: Closed,
61            actor: props::Actor,
62            object: props::Object,
63            target: Target,
64            result: props::Result,
65            origin: Origin,
66            instrument: Instrument,
67            total_items: TotalItems,
68            current: Current,
69            first: First,
70            last: Last,
71            items alias "orderedItems": Items,
72            part_of: PartOf,
73            next: Next,
74            prev: Prev,
75            start_index: StartIndex,
76            accuracy: Accuracy,
77            altitude: Altitude,
78            latitude: Latitude,
79            longitude: Longitude,
80            radius: Radius,
81            units: Units,
82            describes: Describes,
83            subject: Subject,
84            relationship: props::Relationship,
85            former_type: FormerType,
86            deleted: Deleted,
87            public_key: PublicKey,
88            public_key_pem: PublicKeyPem,
89            preferred_username: PreferredUsername,
90            owner: Owner,
91            inbox: Inbox,
92            outbox: Outbox,
93            followers: Followers,
94            following: Following,
95        },
96    },
97    LinkTrait {
98        Link {
99            kind rename "type": Kind,
100            href: Href,
101            rel: Rel,
102            media_type: MediaType,
103            name alias "nameMap": Name,
104            href_lang: HrefLang,
105            heigh: Height,
106            width: Width,
107            preview: Preview,
108        },
109    },
110}