rustpub 0.1.8

An implementation of the Activitypub types
Documentation
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,
        },
    },
}