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
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
use serde::{Deserialize, Serialize};

use crate::simple::properties as props;
use crate::simple::properties::*;

use rustpub_macro::activitypub_complex;

#[derive(Clone, Debug, Deserialize, Serialize)]
struct CoreKind {
    #[serde(rename = "type")]
    kind: Kind,
}

pub fn core_kind(input: &str) -> std::result::Result<Kind, serde_json::Error> {
    let core_kind: CoreKind = serde_json::from_str(input)?;
    Ok(core_kind.kind)
}

activitypub_complex! {
    base_traits {
        ObjectBaseTrait,
        LinkBaseTrait,
    }
    group_traits {
        ObjectTrait: ObjectBaseTrait,
        LinkTrait: LinkBaseTrait,
    }
    ObjectTrait {
        Object {
            id: Id,
            kind rename "type": Kind,
            attachment: Attachment,
            attributed_to: AttributedTo,
            audience: Audience,
            content alias "contentMap": Content,
            context rename "@context": Context,
            name alias "nameMap": Name,
            end_time: EndTime,
            generator: Generator,
            icon: Icon,
            image: props::Image,
            in_reply_to: InReplyTo,
            location: Location,
            preview: Preview,
            published: Published,
            replies: Replies,
            start_time: StartTime,
            summary alias "summaryMap": Summary,
            tag: Tag,
            updated: Updated,
            url: Url,
            to: To,
            bto: BTo,
            cc: CC,
            bcc: BCC,
            media_type: MediaType,
            duration: Duration,
            one_of: OneOf,
            any_of: AnyOf,
            closed: Closed,
            actor: props::Actor,
            object: props::Object,
            target: Target,
            result: props::Result,
            origin: Origin,
            instrument: Instrument,
            total_items: TotalItems,
            current: Current,
            first: First,
            last: Last,
            items alias "orderedItems": Items,
            part_of: PartOf,
            next: Next,
            prev: Prev,
            start_index: StartIndex,
            accuracy: Accuracy,
            altitude: Altitude,
            latitude: Latitude,
            longitude: Longitude,
            radius: Radius,
            units: Units,
            describes: Describes,
            subject: Subject,
            relationship: props::Relationship,
            former_type: FormerType,
            deleted: Deleted,
            public_key: PublicKey,
            public_key_pem: PublicKeyPem,
            preferred_username: PreferredUsername,
            owner: Owner,
            inbox: Inbox,
            outbox: Outbox,
            followers: Followers,
            following: Following,
        },
    },
    LinkTrait {
        Link {
            kind rename "type": Kind,
            href: Href,
            rel: Rel,
            media_type: MediaType,
            name alias "nameMap": Name,
            href_lang: HrefLang,
            heigh: Height,
            width: Width,
            preview: Preview,
        },
    },
}