activitystreams/src/object/mod.rs

193 lines
4.3 KiB
Rust
Raw Normal View History

2018-05-12 20:14:43 +00:00
/*
* This file is part of ActivityStreams.
*
* Copyright © 2018 Riley Trautman
*
* ActivityStreams is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ActivityStreams is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>.
*/
2018-05-12 05:39:47 +00:00
use serde::{de::DeserializeOwned, ser::Serialize};
2018-05-12 05:31:33 +00:00
use serde_json;
use link::Link;
mod kind;
mod properties;
pub use self::kind::*;
pub use self::properties::*;
2018-05-12 05:39:47 +00:00
pub trait Object: DeserializeOwned + Serialize {}
2018-05-12 05:31:33 +00:00
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Article {
#[serde(rename = "type")]
kind: ArticleType,
2018-05-12 05:31:33 +00:00
#[serde(flatten)]
pub object_props: ObjectProperties,
}
impl Object for Article {}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Audio {
#[serde(rename = "type")]
kind: AudioType,
2018-05-12 05:31:33 +00:00
#[serde(flatten)]
pub object_props: ObjectProperties,
}
impl Object for Audio {}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Document {
#[serde(rename = "type")]
kind: DocumentType,
2018-05-12 05:31:33 +00:00
#[serde(flatten)]
pub object_props: ObjectProperties,
}
impl Object for Document {}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Event {
#[serde(rename = "type")]
kind: EventType,
2018-05-12 05:31:33 +00:00
#[serde(flatten)]
pub object_props: ObjectProperties,
}
impl Object for Event {}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Image {
#[serde(rename = "type")]
kind: ImageType,
2018-05-12 05:31:33 +00:00
#[serde(flatten)]
pub object_props: ObjectProperties,
}
impl Object for Image {}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Note {
#[serde(rename = "type")]
kind: NoteType,
2018-05-12 05:31:33 +00:00
#[serde(flatten)]
pub object_props: ObjectProperties,
}
impl Object for Note {}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Page {
#[serde(rename = "type")]
kind: PageType,
2018-05-12 05:31:33 +00:00
#[serde(flatten)]
pub object_props: ObjectProperties,
}
impl Object for Page {}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Place {
#[serde(rename = "type")]
kind: PlaceType,
2018-05-12 05:31:33 +00:00
#[serde(flatten)]
pub object_props: ObjectProperties,
2018-05-12 05:31:33 +00:00
#[serde(flatten)]
pub place: PlaceProperties,
}
impl Object for Place {}
#[derive(Clone, Debug, Serialize, Deserialize, Properties)]
2018-05-12 05:31:33 +00:00
#[serde(rename_all = "camelCase")]
pub struct Profile {
#[serde(rename = "type")]
kind: ProfileType,
#[activitystreams(ab(Object), functional)]
2018-05-12 05:31:33 +00:00
describes: serde_json::Value,
2018-05-12 05:31:33 +00:00
#[serde(flatten)]
pub object_props: ObjectProperties,
}
impl Object for Profile {}
#[derive(Clone, Debug, Serialize, Deserialize, Properties)]
2018-05-12 05:31:33 +00:00
#[serde(rename_all = "camelCase")]
pub struct Relationship {
#[serde(rename = "type")]
kind: RelationshipType,
#[activitystreams(ab(Object, Link))]
2018-05-12 05:31:33 +00:00
subject: serde_json::Value,
#[activitystreams(ab(Object, Link))]
2018-05-12 05:31:33 +00:00
object: serde_json::Value,
#[activitystreams(ab(Object))]
2018-05-12 05:31:33 +00:00
relationship: serde_json::Value,
2018-05-12 05:31:33 +00:00
#[serde(flatten)]
pub object_props: ObjectProperties,
}
impl Object for Relationship {}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Tombstone {
#[serde(rename = "type")]
kind: TombstoneType,
2018-05-12 05:31:33 +00:00
#[serde(flatten)]
pub object_props: ObjectProperties,
2018-05-12 05:31:33 +00:00
#[serde(flatten)]
pub tombstone_props: TombstoneProperties,
}
impl Object for Tombstone {}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Video {
#[serde(rename = "type")]
kind: VideoType,
2018-05-12 05:31:33 +00:00
#[serde(flatten)]
pub object_props: ObjectProperties,
}
impl Object for Video {}