Drop typetag in favor of serde_json::Value

This commit is contained in:
asonix 2020-03-13 15:54:29 -05:00
parent 6f5fb994d3
commit c6a0027e7a
54 changed files with 1498 additions and 2195 deletions

View file

@ -1,7 +1,7 @@
[package]
name = "activitystreams"
description = "Activity Streams in Rust"
version = "0.4.0"
version = "0.5.0-alpha.0"
license = "GPL-3.0"
authors = ["asonix <asonix@asonix.dog>"]
repository = "https://git.asonix.dog/Aardwolf/activitystreams"
@ -14,14 +14,14 @@ default = ["types"]
derive = ["activitystreams-derive"]
kinds = ["derive", "serde"]
primitives = ["chrono", "mime", "serde", "thiserror", "url"]
types = ["derive", "kinds", "primitives", "serde"]
types = ["derive", "kinds", "primitives", "serde", "serde_json"]
[dependencies]
activitystreams-derive = { version = "0.4.0", path = "activitystreams-derive", optional = true}
typetag = "0.1.4"
activitystreams-derive = { version = "0.5.0-alpha.0", path = "activitystreams-derive", optional = true}
chrono = { version = "0.4", optional = true }
mime = { version = "0.3", optional = true }
serde = { version = "1.0", features = ["derive"], optional = true }
serde_json = { version = "1.0", optional = true }
thiserror = { version = "1.0", optional = true }
url = { version = "2.1", optional = true }

View file

@ -1,7 +1,7 @@
[package]
name = "activitystreams-derive"
description = "Derive macros for activitystreams"
version = "0.4.0"
version = "0.5.0-alpha.0"
license = "GPL-3.0"
authors = ["asonix <asonix.dev@gmail.com>"]
repository = "https://git.asonix.dog/Aardwolf/activitystreams"
@ -11,7 +11,7 @@ edition = "2018"
[dependencies]
quote = "1.0"
syn = "1.0"
syn = { version = "1.0", features = ["full"] }
proc-macro2 = "1.0"
[dev-dependencies]

View file

@ -32,7 +32,7 @@ use activitystreams::object::properties::ObjectProperties;
/// This macro implements Serialize and Deserialize for the given type, making this type
/// represent the string "SomeKind" in JSON.
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(SomeKind)]
#[unit_string(SomeKind)]
pub struct MyKind;
properties! {
@ -80,17 +80,18 @@ properties! {
#[derive(Clone, Default, PropRefs, serde::Deserialize, serde::Serialize)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
pub struct My {
/// Derive AsRef<MyProperties> and AsMut<MyProperties>
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
my_properties: MyProperties,
/// Derive AsRef<ObjectProperties> and AsMut<ObjectProperties>
///
/// as well as the Object trait
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
properties: ObjectProperties,
}

View file

@ -38,7 +38,7 @@
//! /// This macro implements Serialize and Deserialize for the given type, making this type
//! /// represent the string "SomeKind" in JSON.
//! #[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd, UnitString)]
//! #[activitystreams(SomeKind)]
//! #[unit_string(SomeKind)]
//! pub struct MyKind;
//!
//! /// Using the properties macro
@ -107,17 +107,18 @@ use syn::{
///
/// ```ignore
/// #[derive(Clone, Debug, serde::Deserialize, serde::Serialize, PropRefs)]
/// #[prop_refs(Object)]
/// pub struct MyStruct {
/// /// Derive AsRef<MyProperties> and AsMut<MyProperties> delegating to `my_field`
/// #[activitystreams(None)]
/// #[prop_refs]
/// my_field: MyProperties,
///
/// /// Derive the above, plus Object (activitystreams)
/// #[activitystreams(Object)]
/// #[prop_refs]
/// obj_field: ObjectProperties,
/// }
/// ```
#[proc_macro_derive(PropRefs, attributes(activitystreams))]
#[proc_macro_derive(PropRefs, attributes(prop_refs))]
pub fn ref_derive(input: TokenStream) -> TokenStream {
let input: DeriveInput = syn::parse(input).unwrap();
@ -133,6 +134,39 @@ pub fn ref_derive(input: TokenStream) -> TokenStream {
_ => panic!("Can only derive for named fields"),
};
let name2 = name.clone();
let base_impls: proc_macro2::TokenStream = input
.attrs
.iter()
.filter_map(move |attr| {
if attr
.path
.segments
.last()
.map(|segment| segment.ident == "prop_refs")
.unwrap_or(false)
{
let object = from_value(attr.clone());
let name = name2.clone();
let box_name = Ident::new(&format!("{}Box", object), name.span());
Some(quote! {
impl #object for #name {}
impl std::convert::TryFrom<#name> for #box_name {
type Error = serde_json::Error;
fn try_from(s: #name) -> Result<Self, Self::Error> {
#box_name::from_concrete(s)
}
}
})
} else {
None
}
})
.collect();
let tokens: proc_macro2::TokenStream = fields
.named
.iter()
@ -142,48 +176,15 @@ pub fn ref_derive(input: TokenStream) -> TokenStream {
.path
.segments
.last()
.map(|segment| {
segment.ident == Ident::new("activitystreams", segment.ident.span())
})
.map(|segment| segment.ident == "prop_refs")
.unwrap_or(false)
});
our_attr.map(move |our_attr| {
(
field.ident.clone().unwrap(),
field.ty.clone(),
our_attr.clone(),
)
our_attr.map(move |_| (field.ident.clone().unwrap(), field.ty.clone()))
})
})
.flat_map(move |(ident, ty, attr)| {
let object = from_value(attr);
.map(move |(ident, ty)| {
let name = name.clone();
let base_impl = if object.to_string() == "Object" || object.to_string() == "Link" {
quote! {
#[typetag::serde]
impl #object for #name {
fn as_any(&self) -> &dyn std::any::Any {
self
}
fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
self
}
fn duplicate(&self) -> Box<dyn #object> {
Box::new(self.clone())
}
}
}
} else {
quote! {
impl #object for #name {}
}
};
let ref_impls = quote! {
impl AsRef<#ty> for #name {
fn as_ref(&self) -> &#ty {
&self.#ident
@ -195,38 +196,138 @@ pub fn ref_derive(input: TokenStream) -> TokenStream {
&mut self.#ident
}
}
};
if object == "None" {
ref_impls
} else {
quote! {
#ref_impls
#base_impl
}
}
})
.collect();
let full = quote! {
#base_impls
#tokens
};
full.into()
}
/// Derive a wrapper type based on serde_json::Value to contain any possible trait type
///
/// The following code
/// ```ignore
/// #[wrapper_type]
/// pub trait Object {}
/// ```
/// produces the following type
/// ```ignore
/// pub struct ObjectBox(pub serde_json::Value);
///
/// impl ObjectBox {
/// pub fn from_concrete<T>(t: T) -> Result<Self, serde_json::Error>
/// where
/// T: Object + serde::ser::Serialize,
/// {
/// Ok(ObjectBox(serde_json::to_value(t)?))
/// }
///
/// pub fn to_concrete<T>(self) -> Result<T, serde_json::Error>
/// where
/// T: Object + serde::de::DeserializeOwned,
/// {
/// serde_json::from_value(self.0)
/// }
///
/// pub fn is_type(&self, kind: impl std::fmt::Display) -> bool {
/// self.0["type"] == kind.to_string()
/// }
///
/// pub fn type(&self) -> Option<&str> {
/// match self.0["type"] {
/// serde_json::Value::String(ref s) -> Some(s),
/// _ => None,
/// }
/// }
/// }
#[proc_macro_attribute]
pub fn wrapper_type(_: TokenStream, input: TokenStream) -> TokenStream {
let input: syn::ItemTrait = syn::parse(input).unwrap();
let trait_name = input.ident.clone();
let type_name = Ident::new(&format!("{}Box", trait_name), trait_name.span());
let tokens = quote! {
#input
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
#[serde(transparent)]
pub struct #type_name(pub serde_json::Value);
impl #type_name {
/// Create the wrapper type from a concrete type
pub fn from_concrete<T>(t: T) -> Result<Self, serde_json::Error>
where
T: #trait_name + serde::ser::Serialize,
{
Ok(#type_name(serde_json::to_value(t)?))
}
/// Attempt to deserialize the wrapper type to a concrete type
pub fn to_concrete<T>(self) -> Result<T, serde_json::Error>
where
T: #trait_name + serde::de::DeserializeOwned,
{
serde_json::from_value(self.0)
}
/// Return whether the given wrapper type is expected.
///
/// For example
/// ```ignore
/// use activitystreams::object::{
/// kind::ImageType,
/// apub::Image,
/// };
/// if my_wrapper_type.is_kind(ImageType) {
/// let image = my_wrapper_type.to_concrete::<Image>()?;
/// ...
/// }
/// ```
pub fn is_kind(&self, kind: impl std::fmt::Display) -> bool {
self.0["type"] == kind.to_string()
}
/// Return the kind of wrapper type, if present
///
/// Example
/// ```ignore
/// match my_wrapper_type.kind() {
/// Some("Image") => {
/// let image = my_wrapper_type.to_concrete::<Image>()?;
/// ...
/// }
/// _ => ...,
/// }
/// ```
pub fn kind(&self) -> Option<&str> {
match self.0["type"] {
serde_json::Value::String(ref s) => Some(s),
_ => None,
}
}
}
};
tokens.into()
}
/// Derive implementations Serialize and Deserialize for a constant string Struct type
///
/// ```ignore
/// /// Derive Serialize and Deserialize such that MyStruct becomes the "MyType" string
/// #[derive(Clone, Debug, UnitString)]
/// #[activitystreams(MyType)]
/// #[unit_string(MyType)]
/// pub struct MyStruct;
///
/// // usage
/// let _: HashMap<String, MyStruct> = serde_json::from_str(r#"{"type":"MyType"}"#)?;
/// ```
#[proc_macro_derive(UnitString, attributes(activitystreams))]
#[proc_macro_derive(UnitString, attributes(unit_string))]
pub fn unit_string(input: TokenStream) -> TokenStream {
let input: DeriveInput = syn::parse(input).unwrap();
@ -240,7 +341,7 @@ pub fn unit_string(input: TokenStream) -> TokenStream {
.path
.segments
.last()
.map(|segment| segment.ident == Ident::new("activitystreams", segment.ident.span()))
.map(|segment| segment.ident == "unit_string")
.unwrap_or(false)
})
.unwrap()
@ -302,10 +403,19 @@ pub fn unit_string(input: TokenStream) -> TokenStream {
}
};
let display = quote! {
impl std::fmt::Display for #name {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}", #value)
}
}
};
let c = quote! {
#serialize
#visitor
#deserialize
#display
};
c.into()

55
examples/de.rs Normal file
View file

@ -0,0 +1,55 @@
use activitystreams::{
collection::apub::OrderedCollection,
object::{streams::Page, ObjectBox},
};
use anyhow::Error;
fn main() -> Result<(), Error> {
let collection_json = r#"{
"type": "OrderedCollection",
"id": "http://lemmy_alpha:8540/federation/c/main",
"context": "https://www.w3.org/ns/activitystreams",
"items": [
{
"type": "Page",
"id": "http://lemmy_alpha:8540/federation/post/2",
"attributedTo": "http://lemmy_alpha:8540/federation/u/2",
"content": "test",
"context": "https://www.w3.org/ns/activitystreams",
"name": "test",
"published": "2020-03-13T00:14:41.188634+00:00"
},
{
"type": "Page",
"id": "http://lemmy_alpha:8540/federation/post/1",
"attributedTo": "http://lemmy_alpha:8540/federation/u/2",
"context": "https://www.w3.org/ns/activitystreams",
"name": "test",
"published": "2020-03-13T00:13:56.311479+00:00"
}
],
"totalItems": 2
}"#;
let page_json = r#"{
"type": "Page",
"id": "http://lemmy_alpha:8540/federation/post/2",
"attributedTo": "http://lemmy_alpha:8540/federation/u/2",
"content": "test",
"name": "test",
"published": "2020-03-13T00:14:41.188634+00:00"
}"#;
let page: Page = serde_json::from_str(page_json)?;
println!("{:#?}", page);
let obox: ObjectBox = page.into();
println!("{:#?}", obox);
let obox_string = serde_json::to_string(&obox)?;
println!("{}", obox_string);
let obox: ObjectBox = serde_json::from_str(&obox_string)?;
println!("{:#?}", obox);
let collection: OrderedCollection = serde_json::from_str(collection_json)?;
println!("{:#?}", collection);
Ok(())
}

View file

@ -20,10 +20,13 @@
//! Activity traits and types
use crate::{
activity::{kind::*, properties::*, Activity, IntransitiveActivity},
activity::{
kind::*, properties::*, Activity, ActivityBox, IntransitiveActivity,
IntransitiveActivityBox,
},
object::{
properties::{ApObjectProperties, ObjectProperties},
Object,
Object, ObjectBox,
},
PropRefs,
};
@ -35,24 +38,26 @@ use serde::{Deserialize, Serialize};
/// object has been accepted.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Accept {
#[serde(rename = "type")]
kind: AcceptType,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub accept_props: AcceptProperties,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
#[serde(flatten)]
#[activitystreams(Activity)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
@ -63,24 +68,26 @@ pub struct Accept {
/// originated.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Add {
#[serde(rename = "type")]
kind: AddType,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub add_props: AddProperties,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
#[serde(flatten)]
#[activitystreams(Activity)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
@ -89,24 +96,26 @@ pub struct Add {
/// If the origin or target are not specified, either can be determined by context.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct AMove {
#[serde(rename = "type")]
kind: MoveType,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub move_props: MoveProperties,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
#[serde(flatten)]
#[activitystreams(Activity)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
@ -115,24 +124,26 @@ pub struct AMove {
/// The origin typically has no defined meaning.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Announce {
#[serde(rename = "type")]
kind: AnnounceType,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub announce_props: AnnounceProperties,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
#[serde(flatten)]
#[activitystreams(Activity)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
@ -142,29 +153,30 @@ pub struct Announce {
/// typically has no defined meaning.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
#[prop_refs(IntransitiveActivity)]
pub struct Arrive {
#[serde(rename = "type")]
kind: ArriveType,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub arrive_props: ArriveProperties,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
#[serde(flatten)]
#[activitystreams(Activity)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
impl IntransitiveActivity for Arrive {}
/// Indicates that the actor is blocking the object.
///
/// Blocking is a stronger form of Ignore. The typical use is to support social systems that allow
@ -172,48 +184,52 @@ impl IntransitiveActivity for Arrive {}
/// defined meaning.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Block {
#[serde(rename = "type")]
kind: BlockType,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub block_props: BlockProperties,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
#[serde(flatten)]
#[activitystreams(Activity)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// Indicates that the actor has created the object.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Create {
#[serde(rename = "type")]
kind: CreateType,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub create_props: CreateProperties,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
#[serde(flatten)]
#[activitystreams(Activity)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
@ -222,48 +238,52 @@ pub struct Create {
/// If specified, the origin indicates the context from which the object was deleted.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Delete {
#[serde(rename = "type")]
kind: DeleteType,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub delete_props: DeleteProperties,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
#[serde(flatten)]
#[activitystreams(Activity)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// Indicates that the actor dislikes the object.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Dislike {
#[serde(rename = "type")]
kind: DislikeType,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub dislike_props: DislikeProperties,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
#[serde(flatten)]
#[activitystreams(Activity)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
@ -273,24 +293,26 @@ pub struct Dislike {
/// inappropriate for any number of reasons.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Flag {
#[serde(rename = "type")]
kind: FlagType,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub flag_props: FlagProperties,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
#[serde(flatten)]
#[activitystreams(Activity)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
@ -301,24 +323,26 @@ pub struct Flag {
/// no defined meaning.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Follow {
#[serde(rename = "type")]
kind: FollowType,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub follow_props: FollowProperties,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
#[serde(flatten)]
#[activitystreams(Activity)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
@ -327,24 +351,26 @@ pub struct Follow {
/// The target and origin typically have no defined meaning.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Ignore {
#[serde(rename = "type")]
kind: IgnoreType,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ignore_props: IgnoreProperties,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
#[serde(flatten)]
#[activitystreams(Activity)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
@ -352,24 +378,26 @@ pub struct Ignore {
/// target.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Invite {
#[serde(rename = "type")]
kind: InviteType,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub invite_props: InviteProperties,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
#[serde(flatten)]
#[activitystreams(Activity)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
@ -378,24 +406,26 @@ pub struct Invite {
/// The target and origin typically have no defined meaning
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Join {
#[serde(rename = "type")]
kind: JoinType,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub join_props: JoinProperties,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
#[serde(flatten)]
#[activitystreams(Activity)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
@ -404,24 +434,26 @@ pub struct Join {
/// The target and origin typically have no meaning.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Leave {
#[serde(rename = "type")]
kind: LeaveType,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub leave_props: LeaveProperties,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
#[serde(flatten)]
#[activitystreams(Activity)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
@ -430,48 +462,52 @@ pub struct Leave {
/// The target and origin typically have no defined meaning.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Like {
#[serde(rename = "type")]
kind: LikeType,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub like_props: LikeProperties,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
#[serde(flatten)]
#[activitystreams(Activity)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// Indicates that the actor has listened to the object.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Listen {
#[serde(rename = "type")]
kind: ListenType,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub listen_props: ListenProperties,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
#[serde(flatten)]
#[activitystreams(Activity)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
@ -480,24 +516,26 @@ pub struct Listen {
/// If specified, the target indicates the entity to which the object is being offered.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Offer {
#[serde(rename = "type")]
kind: OfferType,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub offer_props: OfferProperties,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
#[serde(flatten)]
#[activitystreams(Activity)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
@ -511,50 +549,53 @@ pub struct Offer {
/// Question object MUST NOT have both properties.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
#[prop_refs(IntransitiveActivity)]
pub struct Question {
#[serde(rename = "type")]
kind: QuestionType,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub question_props: QuestionProperties,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
#[serde(flatten)]
#[activitystreams(Activity)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
impl IntransitiveActivity for Question {}
/// Indicates that the actor has read the object.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Read {
#[serde(rename = "type")]
kind: ReadType,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub read_props: ReadProperties,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
#[serde(flatten)]
#[activitystreams(Activity)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
@ -563,24 +604,26 @@ pub struct Read {
/// The target and origin typically have no defined meaning.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Reject {
#[serde(rename = "type")]
kind: RejectType,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub reject_props: RejectProperties,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
#[serde(flatten)]
#[activitystreams(Activity)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
@ -589,72 +632,78 @@ pub struct Reject {
/// If specified, the origin indicates the context from which the object is being removed.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Remove {
#[serde(rename = "type")]
kind: RemoveType,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub remove_props: RemoveProperties,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
#[serde(flatten)]
#[activitystreams(Activity)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// A specialization of Accept indicating that the acceptance is tentative.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct TentativeAccept {
#[serde(rename = "type")]
kind: TentativeAcceptType,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub tentative_accept_props: TentativeAcceptProperties,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
#[serde(flatten)]
#[activitystreams(Activity)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// A specialization of Reject in which the rejection is considered tentative.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct TentativeReject {
#[serde(rename = "type")]
kind: TentativeRejectType,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub tentative_reject_props: TentativeRejectProperties,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
#[serde(flatten)]
#[activitystreams(Activity)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
@ -664,29 +713,30 @@ pub struct TentativeReject {
/// origin are not specified, either can be determined by context.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
#[prop_refs(IntransitiveActivity)]
pub struct Travel {
#[serde(rename = "type")]
kind: TravelType,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub travel_props: TravelProperties,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
#[serde(flatten)]
#[activitystreams(Activity)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
impl IntransitiveActivity for Travel {}
/// Indicates that the actor is undoing the object.
///
/// In most cases, the object will be an Activity describing some previously performed action (for
@ -696,24 +746,26 @@ impl IntransitiveActivity for Travel {}
/// The target and origin typically have no defined meaning.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Undo {
#[serde(rename = "type")]
kind: UndoType,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub undo_props: UndoProperties,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
#[serde(flatten)]
#[activitystreams(Activity)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
@ -725,47 +777,51 @@ pub struct Undo {
/// The target and origin typically have no defined meaning.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Update {
#[serde(rename = "type")]
kind: UpdateType,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub update_props: UpdateProperties,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
#[serde(flatten)]
#[activitystreams(Activity)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// Indicates that the actor has viewed the object.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct View {
#[serde(rename = "type")]
kind: ViewType,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub view_props: ViewProperties,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
#[serde(flatten)]
#[activitystreams(Activity)]
#[prop_refs]
pub activity_props: ActivityProperties,
}

View file

@ -22,113 +22,113 @@
use crate::UnitString;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Accept)]
#[unit_string(Accept)]
pub struct AcceptType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Add)]
#[unit_string(Add)]
pub struct AddType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Move)]
#[unit_string(Move)]
pub struct MoveType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Announce)]
#[unit_string(Announce)]
pub struct AnnounceType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Arrive)]
#[unit_string(Arrive)]
pub struct ArriveType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Block)]
#[unit_string(Block)]
pub struct BlockType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Create)]
#[unit_string(Create)]
pub struct CreateType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Delete)]
#[unit_string(Delete)]
pub struct DeleteType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Dislike)]
#[unit_string(Dislike)]
pub struct DislikeType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Flag)]
#[unit_string(Flag)]
pub struct FlagType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Follow)]
#[unit_string(Follow)]
pub struct FollowType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Ignore)]
#[unit_string(Ignore)]
pub struct IgnoreType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Invite)]
#[unit_string(Invite)]
pub struct InviteType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Join)]
#[unit_string(Join)]
pub struct JoinType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Leave)]
#[unit_string(Leave)]
pub struct LeaveType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Like)]
#[unit_string(Like)]
pub struct LikeType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Listen)]
#[unit_string(Listen)]
pub struct ListenType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Offer)]
#[unit_string(Offer)]
pub struct OfferType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Question)]
#[unit_string(Question)]
pub struct QuestionType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Real)]
#[unit_string(Real)]
pub struct ReadType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Reject)]
#[unit_string(Reject)]
pub struct RejectType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Remove)]
#[unit_string(Remove)]
pub struct RemoveType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(TentativeAccept)]
#[unit_string(TentativeAccept)]
pub struct TentativeAcceptType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(TentativeReject)]
#[unit_string(TentativeReject)]
pub struct TentativeRejectType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Travel)]
#[unit_string(Travel)]
pub struct TravelType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Undo)]
#[unit_string(Undo)]
pub struct UndoType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Update)]
#[unit_string(Update)]
pub struct UpdateType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(View)]
#[unit_string(View)]
pub struct ViewType;

View file

@ -26,6 +26,9 @@ pub mod properties;
#[cfg(feature = "types")]
pub mod streams;
#[cfg(feature = "types")]
use crate::wrapper_type;
use crate::object::Object;
/// An Activity is a subtype of `Object` that describes some form of action that may happen, is
@ -34,10 +37,12 @@ use crate::object::Object;
/// The `Activity` type itself serves as an abstract base type for all types of activities. It is
/// important to note that the `Activity` type itself does not carry any specific semantics about
/// the kind of action being taken.
#[cfg_attr(feature = "types", wrapper_type)]
pub trait Activity: Object {}
/// Instances of `IntransitiveActivity` are a subtype of `Activity` representing intransitive
/// actions.
///
/// The `object` property is therefore inappropriate for these activities.
#[cfg_attr(feature = "types", wrapper_type)]
pub trait IntransitiveActivity: Activity {}

850
src/activity/streams.rs Normal file
View file

@ -0,0 +1,850 @@
/*
* This file is part of ActivityStreams.
*
* Copyright © 2020 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/>.
*/
use crate::{
activity::{
kind::*, properties::*, Activity, ActivityBox, IntransitiveActivity,
IntransitiveActivityBox,
},
object::{properties::ObjectProperties, Object, ObjectBox},
PropRefs,
};
use serde::{Deserialize, Serialize};
/// Indicates that the actor accepts the object.
///
/// The target property can be used in certain circumstances to indicate the context into which the
/// object has been accepted.
#[derive(Clone, Debug, Default, Deserialize, PropRefs, Serialize)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Accept {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: AcceptType,
/// Adds all valid accept properties to this struct
#[serde(flatten)]
#[prop_refs]
pub accept_props: AcceptProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// Indicates that the actor has added the object to the target.
///
/// If the target property is not explicitly specified, the target would need to be determined
/// implicitly by context. The origin can be used to identify the context from which the object
/// originated.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Add {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: AddType,
/// Adds all valid add properties to this struct
#[serde(flatten)]
#[prop_refs]
pub add_props: AddProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// Indicates that the actor has moved object from origin to target.
///
/// If the origin or target are not specified, either can be determined by context.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct AMove {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: MoveType,
/// Adds all valid move properties to this struct
#[serde(flatten)]
#[prop_refs]
pub move_props: MoveProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// Indicates that the actor is calling the target's attention the object.
///
/// The origin typically has no defined meaning.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Announce {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: AnnounceType,
/// Adds all valid announce properties to this struct
#[serde(flatten)]
#[prop_refs]
pub announce_props: AnnounceProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// An IntransitiveActivity that indicates that the actor has arrived at the location.
///
/// The origin can be used to identify the context from which the actor originated. The target
/// typically has no defined meaning.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
#[prop_refs(IntransitiveActivity)]
pub struct Arrive {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: ArriveType,
/// Adds all valid arrive properties to this struct
#[serde(flatten)]
#[prop_refs]
pub arrive_props: ArriveProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// Indicates that the actor is blocking the object.
///
/// Blocking is a stronger form of Ignore. The typical use is to support social systems that allow
/// one user to block activities or content of other users. The target and origin typically have no
/// defined meaning.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Block {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: BlockType,
/// Adds all valid block properties to this struct
#[serde(flatten)]
#[prop_refs]
pub block_props: BlockProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// Indicates that the actor has created the object.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Create {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: CreateType,
/// Adds all valid create properties to this struct
#[serde(flatten)]
#[prop_refs]
pub create_props: CreateProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// Indicates that the actor has deleted the object.
///
/// If specified, the origin indicates the context from which the object was deleted.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Delete {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: DeleteType,
/// Adds all valid delete properties to this struct
#[serde(flatten)]
#[prop_refs]
pub delete_props: DeleteProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// Indicates that the actor dislikes the object.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Dislike {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: DislikeType,
/// Adds all valid dislike properties to this struct
#[serde(flatten)]
#[prop_refs]
pub dislike_props: DislikeProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// Indicates that the actor is "flagging" the object.
///
/// Flagging is defined in the sense common to many social platforms as reporting content as being
/// inappropriate for any number of reasons.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Flag {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: FlagType,
/// Adds all valid flag properties to this struct
#[serde(flatten)]
#[prop_refs]
pub flag_props: FlagProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// Indicates that the actor is "following" the object.
///
/// Following is defined in the sense typically used within Social systems in which the actor is
/// interested in any activity performed by or on the object. The target and origin typically have
/// no defined meaning.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Follow {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: FollowType,
/// Adds all valid follow properties to this struct
#[serde(flatten)]
#[prop_refs]
pub follow_props: FollowProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// Indicates that the actor is ignoring the object.
///
/// The target and origin typically have no defined meaning.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Ignore {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: IgnoreType,
/// Adds all valid ignore properties to this struct
#[serde(flatten)]
#[prop_refs]
pub ignore_props: IgnoreProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// A specialization of Offer in which the actor is extending an invitation for the object to the
/// target.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Invite {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: InviteType,
/// Adds all valid invite properties to this struct
#[serde(flatten)]
#[prop_refs]
pub invite_props: InviteProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// Indicates that the actor has joined the object.
///
/// The target and origin typically have no defined meaning
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Join {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: JoinType,
/// Adds all valid join properties to this struct
#[serde(flatten)]
#[prop_refs]
pub join_props: JoinProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// Indicates that the actor has left the object.
///
/// The target and origin typically have no meaning.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Leave {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: LeaveType,
/// Adds all valid leave properties to this struct
#[serde(flatten)]
#[prop_refs]
pub leave_props: LeaveProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// Indicates that the actor likes, recommends or endorses the object.
///
/// The target and origin typically have no defined meaning.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Like {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: LikeType,
/// Adds all valid like properties to this struct
#[serde(flatten)]
#[prop_refs]
pub like_props: LikeProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// Indicates that the actor has listened to the object.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Listen {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
kind: ListenType,
/// Adds all valid listen properties to this struct
#[serde(flatten)]
#[prop_refs]
pub listen_props: ListenProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// Indicates that the actor is offering the object.
///
/// If specified, the target indicates the entity to which the object is being offered.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Offer {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: OfferType,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[prop_refs]
pub offer_props: OfferProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// Represents a question being asked.
///
/// Question objects are an extension of IntransitiveActivity. That is, the Question object is an
/// Activity, but the direct object is the question itself and therefore it would not contain an
/// object property.
///
/// Either of the anyOf and oneOf properties MAY be used to express possible answers, but a
/// Question object MUST NOT have both properties.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
#[prop_refs(IntransitiveActivity)]
pub struct Question {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: QuestionType,
/// Adds all valid question properties to this struct
#[serde(flatten)]
#[prop_refs]
pub question_props: QuestionProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// Indicates that the actor has read the object.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Read {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: ReadType,
/// Adds all valid read properties to this struct
#[serde(flatten)]
#[prop_refs]
pub read_props: ReadProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// Indicates that the actor is rejecting the object.
///
/// The target and origin typically have no defined meaning.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Reject {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: RejectType,
/// Adds all valid reject properties to this struct
#[serde(flatten)]
#[prop_refs]
pub reject_props: RejectProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// Indicates that the actor is removing the object.
///
/// If specified, the origin indicates the context from which the object is being removed.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Remove {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: RemoveType,
/// Adds all valid remove properties to this struct
#[serde(flatten)]
#[prop_refs]
pub remove_props: RemoveProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// A specialization of Accept indicating that the acceptance is tentative.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct TentativeAccept {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: TentativeAcceptType,
/// Adds all valid tentative_accept properties to this struct
#[serde(flatten)]
#[prop_refs]
pub tentative_accept_props: TentativeAcceptProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// A specialization of Reject in which the rejection is considered tentative.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct TentativeReject {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: TentativeRejectType,
/// Adds all valid tentative_reject properties to this struct
#[serde(flatten)]
#[prop_refs]
pub tentative_reject_props: TentativeRejectProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// Indicates that the actor is traveling to target from origin.
///
/// Travel is an IntransitiveObject whose actor specifies the direct object. If the target or
/// origin are not specified, either can be determined by context.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
#[prop_refs(IntransitiveActivity)]
pub struct Travel {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: TravelType,
/// Adds all valid travel properties to this struct
#[serde(flatten)]
#[prop_refs]
pub travel_props: TravelProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// Indicates that the actor is undoing the object.
///
/// In most cases, the object will be an Activity describing some previously performed action (for
/// instance, a person may have previously "liked" an article but, for whatever reason, might
/// choose to undo that like at some later point in time).
///
/// The target and origin typically have no defined meaning.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Undo {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: UndoType,
/// Adds all valid undo properties to this struct
#[serde(flatten)]
#[prop_refs]
pub undo_props: UndoProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// Indicates that the actor has updated the object.
///
/// Note, however, that this vocabulary does not define a mechanism for describing the actual set
/// of modifications made to object.
///
/// The target and origin typically have no defined meaning.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct Update {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: UpdateType,
/// Adds all valid update properties to this struct
#[serde(flatten)]
#[prop_refs]
pub update_props: UpdateProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[prop_refs]
pub activity_props: ActivityProperties,
}
/// Indicates that the actor has viewed the object.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Activity)]
pub struct View {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: ViewType,
/// Adds all valid view properties to this struct
#[serde(flatten)]
#[prop_refs]
pub view_props: ViewProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[prop_refs]
pub activity_props: ActivityProperties,
}

View file

@ -1,57 +0,0 @@
/*
* This file is part of ActivityStreams.
*
* Copyright © 2020 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/>.
*/
use crate::{
activity::{
kind::AcceptType,
properties::{AcceptProperties, ActivityProperties},
Activity,
},
object::{properties::ObjectProperties, Object},
PropRefs,
};
use serde::{Deserialize, Serialize};
/// Indicates that the actor accepts the object.
///
/// The target property can be used in certain circumstances to indicate the context into which the
/// object has been accepted.
#[derive(Clone, Debug, Default, Deserialize, PropRefs, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Accept {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: AcceptType,
/// Adds all valid accept properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
pub accept_props: AcceptProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[activitystreams(Activity)]
pub activity_props: ActivityProperties,
}

View file

@ -1,58 +0,0 @@
/*
* This file is part of ActivityStreams.
*
* Copyright © 2020 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/>.
*/
use crate::{
activity::{
kind::AddType,
properties::{ActivityProperties, AddProperties},
Activity,
},
object::{properties::ObjectProperties, Object},
PropRefs,
};
use serde::{Deserialize, Serialize};
/// Indicates that the actor has added the object to the target.
///
/// If the target property is not explicitly specified, the target would need to be determined
/// implicitly by context. The origin can be used to identify the context from which the object
/// originated.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
pub struct Add {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: AddType,
/// Adds all valid add properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
pub add_props: AddProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[activitystreams(Activity)]
pub activity_props: ActivityProperties,
}

View file

@ -1,56 +0,0 @@
/*
* This file is part of ActivityStreams.
*
* Copyright © 2020 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/>.
*/
use crate::{
activity::{
kind::MoveType,
properties::{ActivityProperties, MoveProperties},
Activity,
},
object::{properties::ObjectProperties, Object},
PropRefs,
};
use serde::{Deserialize, Serialize};
/// Indicates that the actor has moved object from origin to target.
///
/// If the origin or target are not specified, either can be determined by context.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
pub struct AMove {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: MoveType,
/// Adds all valid move properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
pub move_props: MoveProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[activitystreams(Activity)]
pub activity_props: ActivityProperties,
}

View file

@ -1,56 +0,0 @@
/*
* This file is part of ActivityStreams.
*
* Copyright © 2020 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/>.
*/
use crate::{
activity::{
kind::AnnounceType,
properties::{ActivityProperties, AnnounceProperties},
Activity,
},
object::{properties::ObjectProperties, Object},
PropRefs,
};
use serde::{Deserialize, Serialize};
/// Indicates that the actor is calling the target's attention the object.
///
/// The origin typically has no defined meaning.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
pub struct Announce {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: AnnounceType,
/// Adds all valid announce properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
pub announce_props: AnnounceProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[activitystreams(Activity)]
pub activity_props: ActivityProperties,
}

View file

@ -1,59 +0,0 @@
/*
* This file is part of ActivityStreams.
*
* Copyright © 2020 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/>.
*/
use crate::{
activity::{
kind::ArriveType,
properties::{ActivityProperties, ArriveProperties},
Activity, IntransitiveActivity,
},
object::{properties::ObjectProperties, Object},
PropRefs,
};
use serde::{Deserialize, Serialize};
/// An IntransitiveActivity that indicates that the actor has arrived at the location.
///
/// The origin can be used to identify the context from which the actor originated. The target
/// typically has no defined meaning.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
pub struct Arrive {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: ArriveType,
/// Adds all valid arrive properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
pub arrive_props: ArriveProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[activitystreams(Activity)]
pub activity_props: ActivityProperties,
}
impl IntransitiveActivity for Arrive {}

View file

@ -1,58 +0,0 @@
/*
* This file is part of ActivityStreams.
*
* Copyright © 2020 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/>.
*/
use crate::{
activity::{
kind::BlockType,
properties::{ActivityProperties, BlockProperties},
Activity,
},
object::{properties::ObjectProperties, Object},
PropRefs,
};
use serde::{Deserialize, Serialize};
/// Indicates that the actor is blocking the object.
///
/// Blocking is a stronger form of Ignore. The typical use is to support social systems that allow
/// one user to block activities or content of other users. The target and origin typically have no
/// defined meaning.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
pub struct Block {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: BlockType,
/// Adds all valid block properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
pub block_props: BlockProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[activitystreams(Activity)]
pub activity_props: ActivityProperties,
}

View file

@ -1,54 +0,0 @@
/*
* This file is part of ActivityStreams.
*
* Copyright © 2020 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/>.
*/
use crate::{
activity::{
kind::CreateType,
properties::{ActivityProperties, CreateProperties},
Activity,
},
object::{properties::ObjectProperties, Object},
PropRefs,
};
use serde::{Deserialize, Serialize};
/// Indicates that the actor has created the object.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
pub struct Create {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: CreateType,
/// Adds all valid create properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
pub create_props: CreateProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[activitystreams(Activity)]
pub activity_props: ActivityProperties,
}

View file

@ -1,56 +0,0 @@
/*
* This file is part of ActivityStreams.
*
* Copyright © 2020 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/>.
*/
use crate::{
activity::{
kind::DeleteType,
properties::{ActivityProperties, DeleteProperties},
Activity,
},
object::{properties::ObjectProperties, Object},
PropRefs,
};
use serde::{Deserialize, Serialize};
/// Indicates that the actor has deleted the object.
///
/// If specified, the origin indicates the context from which the object was deleted.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
pub struct Delete {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: DeleteType,
/// Adds all valid delete properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
pub delete_props: DeleteProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[activitystreams(Activity)]
pub activity_props: ActivityProperties,
}

View file

@ -1,54 +0,0 @@
/*
* This file is part of ActivityStreams.
*
* Copyright © 2020 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/>.
*/
use crate::{
activity::{
kind::DislikeType,
properties::{ActivityProperties, DislikeProperties},
Activity,
},
object::{properties::ObjectProperties, Object},
PropRefs,
};
use serde::{Deserialize, Serialize};
/// Indicates that the actor dislikes the object.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
pub struct Dislike {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: DislikeType,
/// Adds all valid dislike properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
pub dislike_props: DislikeProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[activitystreams(Activity)]
pub activity_props: ActivityProperties,
}

View file

@ -1,57 +0,0 @@
/*
* This file is part of ActivityStreams.
*
* Copyright © 2020 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/>.
*/
use crate::{
activity::{
kind::FlagType,
properties::{ActivityProperties, FlagProperties},
Activity,
},
object::{properties::ObjectProperties, Object},
PropRefs,
};
use serde::{Deserialize, Serialize};
/// Indicates that the actor is "flagging" the object.
///
/// Flagging is defined in the sense common to many social platforms as reporting content as being
/// inappropriate for any number of reasons.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
pub struct Flag {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: FlagType,
/// Adds all valid flag properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
pub flag_props: FlagProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[activitystreams(Activity)]
pub activity_props: ActivityProperties,
}

View file

@ -1,58 +0,0 @@
/*
* This file is part of ActivityStreams.
*
* Copyright © 2020 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/>.
*/
use crate::{
activity::{
kind::FollowType,
properties::{ActivityProperties, FollowProperties},
Activity,
},
object::{properties::ObjectProperties, Object},
PropRefs,
};
use serde::{Deserialize, Serialize};
/// Indicates that the actor is "following" the object.
///
/// Following is defined in the sense typically used within Social systems in which the actor is
/// interested in any activity performed by or on the object. The target and origin typically have
/// no defined meaning.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
pub struct Follow {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: FollowType,
/// Adds all valid follow properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
pub follow_props: FollowProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[activitystreams(Activity)]
pub activity_props: ActivityProperties,
}

View file

@ -1,56 +0,0 @@
/*
* This file is part of ActivityStreams.
*
* Copyright © 2020 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/>.
*/
use crate::{
activity::{
kind::IgnoreType,
properties::{ActivityProperties, IgnoreProperties},
Activity,
},
object::{properties::ObjectProperties, Object},
PropRefs,
};
use serde::{Deserialize, Serialize};
/// Indicates that the actor is ignoring the object.
///
/// The target and origin typically have no defined meaning.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
pub struct Ignore {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: IgnoreType,
/// Adds all valid ignore properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
pub ignore_props: IgnoreProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[activitystreams(Activity)]
pub activity_props: ActivityProperties,
}

View file

@ -1,55 +0,0 @@
/*
* This file is part of ActivityStreams.
*
* Copyright © 2020 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/>.
*/
use crate::{
activity::{
kind::InviteType,
properties::{ActivityProperties, InviteProperties},
Activity,
},
object::{properties::ObjectProperties, Object},
PropRefs,
};
use serde::{Deserialize, Serialize};
/// A specialization of Offer in which the actor is extending an invitation for the object to the
/// target.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
pub struct Invite {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: InviteType,
/// Adds all valid invite properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
pub invite_props: InviteProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[activitystreams(Activity)]
pub activity_props: ActivityProperties,
}

View file

@ -1,56 +0,0 @@
/*
* This file is part of ActivityStreams.
*
* Copyright © 2020 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/>.
*/
use crate::{
activity::{
kind::JoinType,
properties::{ActivityProperties, JoinProperties},
Activity,
},
object::{properties::ObjectProperties, Object},
PropRefs,
};
use serde::{Deserialize, Serialize};
/// Indicates that the actor has joined the object.
///
/// The target and origin typically have no defined meaning
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
pub struct Join {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: JoinType,
/// Adds all valid join properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
pub join_props: JoinProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[activitystreams(Activity)]
pub activity_props: ActivityProperties,
}

View file

@ -1,56 +0,0 @@
/*
* This file is part of ActivityStreams.
*
* Copyright © 2020 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/>.
*/
use crate::{
activity::{
kind::LeaveType,
properties::{ActivityProperties, LeaveProperties},
Activity,
},
object::{properties::ObjectProperties, Object},
PropRefs,
};
use serde::{Deserialize, Serialize};
/// Indicates that the actor has left the object.
///
/// The target and origin typically have no meaning.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
pub struct Leave {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: LeaveType,
/// Adds all valid leave properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
pub leave_props: LeaveProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[activitystreams(Activity)]
pub activity_props: ActivityProperties,
}

View file

@ -1,56 +0,0 @@
/*
* This file is part of ActivityStreams.
*
* Copyright © 2020 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/>.
*/
use crate::{
activity::{
kind::LikeType,
properties::{ActivityProperties, LikeProperties},
Activity,
},
object::{properties::ObjectProperties, Object},
PropRefs,
};
use serde::{Deserialize, Serialize};
/// Indicates that the actor likes, recommends or endorses the object.
///
/// The target and origin typically have no defined meaning.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
pub struct Like {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: LikeType,
/// Adds all valid like properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
pub like_props: LikeProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[activitystreams(Activity)]
pub activity_props: ActivityProperties,
}

View file

@ -1,54 +0,0 @@
/*
* This file is part of ActivityStreams.
*
* Copyright © 2020 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/>.
*/
use crate::{
activity::{
kind::ListenType,
properties::{ActivityProperties, ListenProperties},
Activity,
},
object::{properties::ObjectProperties, Object},
PropRefs,
};
use serde::{Deserialize, Serialize};
/// Indicates that the actor has listened to the object.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
pub struct Listen {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
kind: ListenType,
/// Adds all valid listen properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
pub listen_props: ListenProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[activitystreams(Activity)]
pub activity_props: ActivityProperties,
}

View file

@ -1,56 +0,0 @@
/*
* This file is part of ActivityStreams.
*
* Copyright © 2020 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/>.
*/
mod accept;
mod add;
mod amove;
mod announce;
mod arrive;
mod block;
mod create;
mod delete;
mod dislike;
mod flag;
mod follow;
mod ignore;
mod invite;
mod join;
mod leave;
mod like;
mod listen;
mod offer;
mod question;
mod read;
mod reject;
mod remove;
mod tentative_accept;
mod tentative_reject;
mod travel;
mod undo;
mod update;
mod view;
pub use self::{
accept::Accept, add::Add, amove::AMove, announce::Announce, arrive::Arrive, block::Block,
create::Create, delete::Delete, dislike::Dislike, flag::Flag, follow::Follow, ignore::Ignore,
invite::Invite, join::Join, leave::Leave, like::Like, listen::Listen, offer::Offer,
question::Question, read::Read, reject::Reject, remove::Remove,
tentative_accept::TentativeAccept, tentative_reject::TentativeReject, travel::Travel,
undo::Undo, update::Update, view::View,
};

View file

@ -1,56 +0,0 @@
/*
* This file is part of ActivityStreams.
*
* Copyright © 2020 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/>.
*/
use crate::{
activity::{
kind::OfferType,
properties::{ActivityProperties, OfferProperties},
Activity,
},
object::{properties::ObjectProperties, Object},
PropRefs,
};
use serde::{Deserialize, Serialize};
/// Indicates that the actor is offering the object.
///
/// If specified, the target indicates the entity to which the object is being offered.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
pub struct Offer {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: OfferType,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
pub offer_props: OfferProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[activitystreams(Activity)]
pub activity_props: ActivityProperties,
}

View file

@ -1,63 +0,0 @@
/*
* This file is part of ActivityStreams.
*
* Copyright © 2020 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/>.
*/
use crate::{
activity::{
kind::QuestionType,
properties::{ActivityProperties, QuestionProperties},
Activity, IntransitiveActivity,
},
object::{properties::ObjectProperties, Object},
PropRefs,
};
use serde::{Deserialize, Serialize};
/// Represents a question being asked.
///
/// Question objects are an extension of IntransitiveActivity. That is, the Question object is an
/// Activity, but the direct object is the question itself and therefore it would not contain an
/// object property.
///
/// Either of the anyOf and oneOf properties MAY be used to express possible answers, but a
/// Question object MUST NOT have both properties.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
pub struct Question {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: QuestionType,
/// Adds all valid question properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
pub question_props: QuestionProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[activitystreams(Activity)]
pub activity_props: ActivityProperties,
}
impl IntransitiveActivity for Question {}

View file

@ -1,54 +0,0 @@
/*
* This file is part of ActivityStreams.
*
* Copyright © 2020 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/>.
*/
use crate::{
activity::{
kind::ReadType,
properties::{ActivityProperties, ReadProperties},
Activity,
},
object::{properties::ObjectProperties, Object},
PropRefs,
};
use serde::{Deserialize, Serialize};
/// Indicates that the actor has read the object.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
pub struct Read {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: ReadType,
/// Adds all valid read properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
pub read_props: ReadProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[activitystreams(Activity)]
pub activity_props: ActivityProperties,
}

View file

@ -1,56 +0,0 @@
/*
* This file is part of ActivityStreams.
*
* Copyright © 2020 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/>.
*/
use crate::{
activity::{
kind::RejectType,
properties::{ActivityProperties, RejectProperties},
Activity,
},
object::{properties::ObjectProperties, Object},
PropRefs,
};
use serde::{Deserialize, Serialize};
/// Indicates that the actor is rejecting the object.
///
/// The target and origin typically have no defined meaning.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
pub struct Reject {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: RejectType,
/// Adds all valid reject properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
pub reject_props: RejectProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[activitystreams(Activity)]
pub activity_props: ActivityProperties,
}

View file

@ -1,56 +0,0 @@
/*
* This file is part of ActivityStreams.
*
* Copyright © 2020 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/>.
*/
use crate::{
activity::{
kind::RemoveType,
properties::{ActivityProperties, RemoveProperties},
Activity,
},
object::{properties::ObjectProperties, Object},
PropRefs,
};
use serde::{Deserialize, Serialize};
/// Indicates that the actor is removing the object.
///
/// If specified, the origin indicates the context from which the object is being removed.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
pub struct Remove {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: RemoveType,
/// Adds all valid remove properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
pub remove_props: RemoveProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[activitystreams(Activity)]
pub activity_props: ActivityProperties,
}

View file

@ -1,54 +0,0 @@
/*
* This file is part of ActivityStreams.
*
* Copyright © 2020 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/>.
*/
use crate::{
activity::{
kind::TentativeAcceptType,
properties::{ActivityProperties, TentativeAcceptProperties},
Activity,
},
object::{properties::ObjectProperties, Object},
PropRefs,
};
use serde::{Deserialize, Serialize};
/// A specialization of Accept indicating that the acceptance is tentative.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
pub struct TentativeAccept {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: TentativeAcceptType,
/// Adds all valid tentative_accept properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
pub tentative_accept_props: TentativeAcceptProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[activitystreams(Activity)]
pub activity_props: ActivityProperties,
}

View file

@ -1,54 +0,0 @@
/*
* This file is part of ActivityStreams.
*
* Copyright © 2020 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/>.
*/
use crate::{
activity::{
kind::TentativeRejectType,
properties::{ActivityProperties, TentativeRejectProperties},
Activity,
},
object::{properties::ObjectProperties, Object},
PropRefs,
};
use serde::{Deserialize, Serialize};
/// A specialization of Reject in which the rejection is considered tentative.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
pub struct TentativeReject {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: TentativeRejectType,
/// Adds all valid tentative_reject properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
pub tentative_reject_props: TentativeRejectProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[activitystreams(Activity)]
pub activity_props: ActivityProperties,
}

View file

@ -1,59 +0,0 @@
/*
* This file is part of ActivityStreams.
*
* Copyright © 2020 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/>.
*/
use crate::{
activity::{
kind::TravelType,
properties::{ActivityProperties, TravelProperties},
Activity, IntransitiveActivity,
},
object::{properties::ObjectProperties, Object},
PropRefs,
};
use serde::{Deserialize, Serialize};
/// Indicates that the actor is traveling to target from origin.
///
/// Travel is an IntransitiveObject whose actor specifies the direct object. If the target or
/// origin are not specified, either can be determined by context.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
pub struct Travel {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: TravelType,
/// Adds all valid travel properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
pub travel_props: TravelProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[activitystreams(Activity)]
pub activity_props: ActivityProperties,
}
impl IntransitiveActivity for Travel {}

View file

@ -1,60 +0,0 @@
/*
* This file is part of ActivityStreams.
*
* Copyright © 2020 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/>.
*/
use crate::{
activity::{
kind::UndoType,
properties::{ActivityProperties, UndoProperties},
Activity,
},
object::{properties::ObjectProperties, Object},
PropRefs,
};
use serde::{Deserialize, Serialize};
/// Indicates that the actor is undoing the object.
///
/// In most cases, the object will be an Activity describing some previously performed action (for
/// instance, a person may have previously "liked" an article but, for whatever reason, might
/// choose to undo that like at some later point in time).
///
/// The target and origin typically have no defined meaning.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
pub struct Undo {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: UndoType,
/// Adds all valid undo properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
pub undo_props: UndoProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[activitystreams(Activity)]
pub activity_props: ActivityProperties,
}

View file

@ -1,59 +0,0 @@
/*
* This file is part of ActivityStreams.
*
* Copyright © 2020 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/>.
*/
use crate::{
activity::{
kind::UpdateType,
properties::{ActivityProperties, UpdateProperties},
Activity,
},
object::{properties::ObjectProperties, Object},
PropRefs,
};
use serde::{Deserialize, Serialize};
/// Indicates that the actor has updated the object.
///
/// Note, however, that this vocabulary does not define a mechanism for describing the actual set
/// of modifications made to object.
///
/// The target and origin typically have no defined meaning.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
pub struct Update {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: UpdateType,
/// Adds all valid update properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
pub update_props: UpdateProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[activitystreams(Activity)]
pub activity_props: ActivityProperties,
}

View file

@ -1,54 +0,0 @@
/*
* This file is part of ActivityStreams.
*
* Copyright © 2020 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/>.
*/
use crate::{
activity::{
kind::ViewType,
properties::{ActivityProperties, ViewProperties},
Activity,
},
object::{properties::ObjectProperties, Object},
PropRefs,
};
use serde::{Deserialize, Serialize};
/// Indicates that the actor has viewed the object.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
pub struct View {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
#[serde(alias = "verb")]
pub kind: ViewType,
/// Adds all valid view properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
pub view_props: ViewProperties,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
pub object_props: ObjectProperties,
/// Adds all valid activity properties to this struct
#[serde(flatten)]
#[activitystreams(Activity)]
pub activity_props: ActivityProperties,
}

View file

@ -18,10 +18,10 @@
*/
use crate::{
actor::{kind::*, properties::*, Actor},
actor::{kind::*, properties::*, Actor, ActorBox},
object::{
properties::{ApObjectProperties, ObjectProperties},
Object,
Object, ObjectBox,
},
PropRefs,
};
@ -30,114 +30,124 @@ use serde::{Deserialize, Serialize};
/// Describes a software application.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Actor)]
pub struct Application {
#[serde(rename = "type")]
kind: ApplicationType,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activitypub object properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
/// Adds all valid activitypub actor properties to this struct
#[serde(flatten)]
#[activitystreams(Actor)]
#[prop_refs]
pub ap_actor_props: ApActorProperties,
}
/// Represents a formal or informal collective of Actors.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Actor)]
pub struct Group {
#[serde(rename = "type")]
kind: GroupType,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activitypub object properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
/// Adds all valid activitypub actor properties to this struct
#[serde(flatten)]
#[activitystreams(Actor)]
#[prop_refs]
pub ap_actor_props: ApActorProperties,
}
/// Represents an organization.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Actor)]
pub struct Organization {
#[serde(rename = "type")]
kind: OrganizationType,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activitypub object properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
/// Adds all valid activitypub actor properties to this struct
#[serde(flatten)]
#[activitystreams(Actor)]
#[prop_refs]
pub ap_actor_props: ApActorProperties,
}
/// Represents an individual person.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Actor)]
pub struct Person {
#[serde(rename = "type")]
kind: PersonType,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activitypub object properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
/// Adds all valid activitypub actor properties to this struct
#[serde(flatten)]
#[activitystreams(Actor)]
#[prop_refs]
pub ap_actor_props: ApActorProperties,
}
/// Represents a service of any kind.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Actor)]
pub struct Service {
#[serde(rename = "type")]
kind: ServiceType,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid activitypub object properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
/// Adds all valid activitypub actor properties to this struct
#[serde(flatten)]
#[activitystreams(Actor)]
#[prop_refs]
pub ap_actor_props: ApActorProperties,
}

View file

@ -21,21 +21,21 @@
use crate::UnitString;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Application)]
#[unit_string(Application)]
pub struct ApplicationType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Group)]
#[unit_string(Group)]
pub struct GroupType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Organization)]
#[unit_string(Organization)]
pub struct OrganizationType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Person)]
#[unit_string(Person)]
pub struct PersonType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Service)]
#[unit_string(Service)]
pub struct ServiceType;

View file

@ -30,6 +30,9 @@ pub mod streams;
use crate::object::Object;
#[cfg(feature = "types")]
use crate::wrapper_type;
/// `Actor` types are `Object` types that are capable of performing activities.
///
/// This specification intentionally defines `Actors` in only the most generalized way, stopping
@ -49,4 +52,5 @@ use crate::object::Object;
/// (e.g. VCard) define their own types for describing people. An implementation that wishes, for
/// example, to use a `vcard:Individual` as an `Actor` MUST also identify that `Actor` as a
/// `Person`.
#[cfg_attr(feature = "types", wrapper_type)]
pub trait Actor: Object {}

View file

@ -18,8 +18,8 @@
*/
use crate::{
actor::{kind::*, Actor},
object::{properties::ObjectProperties, Object},
actor::{kind::*, Actor, ActorBox},
object::{properties::ObjectProperties, Object, ObjectBox},
PropRefs,
};
use serde::{Deserialize, Serialize};
@ -27,6 +27,8 @@ use serde::{Deserialize, Serialize};
/// Describes a software application.
#[derive(Clone, Debug, Default, Deserialize, PropRefs, Serialize)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Actor)]
pub struct Application {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
@ -35,15 +37,15 @@ pub struct Application {
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
}
impl Actor for Application {}
/// Represents a formal or informal collective of Actors.
#[derive(Clone, Debug, Default, Deserialize, PropRefs, Serialize)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Actor)]
pub struct Group {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
@ -52,12 +54,10 @@ pub struct Group {
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
}
impl Actor for Group {}
/// Represents an organization.
#[derive(Clone, Debug, Default, Deserialize, PropRefs, Serialize)]
#[serde(rename_all = "camelCase")]
@ -69,15 +69,15 @@ pub struct Organization {
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
}
impl Actor for Organization {}
/// Represents an individual person.
#[derive(Clone, Debug, Default, Deserialize, PropRefs, Serialize)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Actor)]
pub struct Person {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
@ -86,15 +86,15 @@ pub struct Person {
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
}
impl Actor for Person {}
/// Represents a service of any kind.
#[derive(Clone, Debug, Default, Deserialize, PropRefs, Serialize)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Actor)]
pub struct Service {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
@ -103,8 +103,6 @@ pub struct Service {
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
}
impl Actor for Service {}

View file

@ -20,10 +20,12 @@
//! Collection traits and types
use crate::{
collection::{kind::*, properties::*, Collection, CollectionPage},
collection::{
kind::*, properties::*, Collection, CollectionBox, CollectionPage, CollectionPageBox,
},
object::{
properties::{ApObjectProperties, ObjectProperties},
Object,
Object, ObjectBox,
},
PropRefs,
};
@ -32,51 +34,56 @@ use serde::{Deserialize, Serialize};
/// The default `Collection` type.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Collection)]
pub struct UnorderedCollection {
#[serde(rename = "type")]
kind: CollectionType,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid ap object properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
/// Adds all valid collection properties to this struct
#[serde(flatten)]
#[activitystreams(Collection)]
#[prop_refs]
pub collection_props: CollectionProperties,
}
/// Used to represent distinct subsets of items from a `Collection`.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Collection)]
#[prop_refs(CollectionPage)]
pub struct UnorderedCollectionPage {
#[serde(rename = "type")]
kind: CollectionPageType,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid ap object properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
/// Adds all valid collection properties to this struct
#[serde(flatten)]
#[activitystreams(Collection)]
#[prop_refs]
pub collection_props: CollectionProperties,
/// Adds all valid collection page properties to this struct
#[serde(flatten)]
#[activitystreams(CollectionPage)]
#[prop_refs]
pub collection_page_props: CollectionPageProperties,
}
@ -84,55 +91,60 @@ pub struct UnorderedCollectionPage {
/// strictly ordered.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Collection)]
pub struct OrderedCollection {
#[serde(rename = "type")]
kind: OrderedCollectionType,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid ap object properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
/// Adds all valid collection properties to this struct
#[serde(flatten)]
#[activitystreams(Collection)]
#[prop_refs]
pub collection_props: CollectionProperties,
}
/// Used to represent ordered subsets of items from an `OrderedCollection`.
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Collection)]
#[prop_refs(CollectionPage)]
pub struct OrderedCollectionPage {
#[serde(rename = "type")]
kind: OrderedCollectionPageType,
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid ap object properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
/// Adds all valid collection properties to this struct
#[serde(flatten)]
#[activitystreams(Collection)]
#[prop_refs]
pub collection_props: CollectionProperties,
/// Adds all valid collection page properties to this struct
#[serde(flatten)]
#[activitystreams(CollectionPage)]
#[prop_refs]
pub collection_page_props: CollectionPageProperties,
/// Adds all valid ordered collection page properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ordered_collection_page_props: OrderedCollectionPageProperties,
}

View file

@ -21,17 +21,17 @@
use crate::UnitString;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Collection)]
#[unit_string(Collection)]
pub struct CollectionType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(CollectionPage)]
#[unit_string(CollectionPage)]
pub struct CollectionPageType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(OrderedCollection)]
#[unit_string(OrderedCollection)]
pub struct OrderedCollectionType;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(OrderedCollectionPage)]
#[unit_string(OrderedCollectionPage)]
pub struct OrderedCollectionPageType;

View file

@ -30,6 +30,9 @@ pub mod streams;
use crate::object::Object;
#[cfg(feature = "types")]
use crate::wrapper_type;
/// A Collection is a subtype of `Object` that represents ordered or unordered sets of `Object` or
/// `Link` instances.
///
@ -40,6 +43,7 @@ use crate::object::Object;
///
/// `UnorderedCollection` and `OrderedCollection` types are provided by the `activitystreams-types`
/// crate.
#[cfg_attr(feature = "types", wrapper_type)]
pub trait Collection: Object {}
/// Used to represent distinct subsets of items from a Collection.
@ -51,96 +55,5 @@ pub trait Collection: Object {}
///
/// `UnorderedCollectionPage` and `OrderedCollectionPage` types are provied by the
/// `activitystreams-types` crate.
#[cfg_attr(feature = "types", wrapper_type)]
pub trait CollectionPage: Collection {}
#[cfg(feature = "types")]
#[derive(Debug, serde::Deserialize, serde::Serialize)]
#[serde(transparent)]
pub struct CollectionBox(pub Box<dyn Object>);
#[cfg(feature = "types")]
#[derive(Debug, serde::Deserialize, serde::Serialize)]
#[serde(transparent)]
pub struct CollectionPageBox(pub Box<dyn Object>);
#[cfg(feature = "types")]
impl CollectionBox {
pub fn is<T>(&self) -> bool
where
T: Collection + 'static,
{
self.0.as_any().is::<T>()
}
pub fn downcast_ref<T>(&self) -> Option<&T>
where
T: Collection + 'static,
{
self.0.as_any().downcast_ref()
}
pub fn downcast_mut<T>(&mut self) -> Option<&mut T>
where
T: Collection + 'static,
{
self.0.as_any_mut().downcast_mut()
}
}
#[cfg(feature = "types")]
impl CollectionPageBox {
pub fn is<T>(&self) -> bool
where
T: CollectionPage + 'static,
{
self.0.as_any().is::<T>()
}
pub fn downcast_ref<T>(&self) -> Option<&T>
where
T: CollectionPage + 'static,
{
self.0.as_any().downcast_ref()
}
pub fn downcast_mut<T>(&mut self) -> Option<&mut T>
where
T: CollectionPage + 'static,
{
self.0.as_any_mut().downcast_mut()
}
}
#[cfg(feature = "types")]
impl Clone for CollectionBox {
fn clone(&self) -> Self {
CollectionBox(self.0.duplicate())
}
}
#[cfg(feature = "types")]
impl Clone for CollectionPageBox {
fn clone(&self) -> Self {
CollectionPageBox(self.0.duplicate())
}
}
#[cfg(feature = "types")]
impl<T> From<T> for CollectionBox
where
T: Collection + 'static,
{
fn from(t: T) -> Self {
CollectionBox(Box::new(t))
}
}
#[cfg(feature = "types")]
impl<T> From<T> for CollectionPageBox
where
T: CollectionPage + 'static,
{
fn from(t: T) -> Self {
CollectionPageBox(Box::new(t))
}
}

View file

@ -20,8 +20,10 @@
//! Namespace for Collection types
use crate::{
collection::{kind::*, properties::*, Collection, CollectionPage},
object::{properties::ObjectProperties, Object},
collection::{
kind::*, properties::*, Collection, CollectionBox, CollectionPage, CollectionPageBox,
},
object::{properties::ObjectProperties, Object, ObjectBox},
PropRefs,
};
use serde::{Deserialize, Serialize};
@ -29,6 +31,8 @@ use serde::{Deserialize, Serialize};
/// The default `Collection` type.
#[derive(Clone, Debug, Default, Deserialize, PropRefs, Serialize)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Collection)]
pub struct UnorderedCollection {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
@ -37,12 +41,12 @@ pub struct UnorderedCollection {
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid collection properties to this struct
#[serde(flatten)]
#[activitystreams(Collection)]
#[prop_refs]
pub collection_props: CollectionProperties,
}
@ -50,6 +54,8 @@ pub struct UnorderedCollection {
/// strictly ordered.
#[derive(Clone, Debug, Default, Deserialize, PropRefs, Serialize)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Collection)]
pub struct OrderedCollection {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
@ -58,18 +64,21 @@ pub struct OrderedCollection {
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid collection properties to this struct
#[serde(flatten)]
#[activitystreams(Collection)]
#[prop_refs]
pub collection_props: CollectionProperties,
}
/// Used to represent distinct subsets of items from a `Collection`.
#[derive(Clone, Debug, Default, Deserialize, PropRefs, Serialize)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Collection)]
#[prop_refs(CollectionPage)]
pub struct UnorderedCollectionPage {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
@ -78,23 +87,26 @@ pub struct UnorderedCollectionPage {
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid collection properties to this struct
#[serde(flatten)]
#[activitystreams(Collection)]
#[prop_refs]
pub collection_props: CollectionProperties,
/// Adds all valid collection page properties to this struct
#[serde(flatten)]
#[activitystreams(CollectionPage)]
#[prop_refs]
pub collection_page_props: CollectionPageProperties,
}
/// Used to represent ordered subsets of items from an `OrderedCollection`.
#[derive(Clone, Debug, Default, Deserialize, PropRefs, Serialize)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
#[prop_refs(Collection)]
#[prop_refs(CollectionPage)]
pub struct OrderedCollectionPage {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
@ -103,21 +115,21 @@ pub struct OrderedCollectionPage {
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid collection properties to this struct
#[serde(flatten)]
#[activitystreams(Collection)]
#[prop_refs]
pub collection_props: CollectionProperties,
/// Adds all valid collection page properties to this struct
#[serde(flatten)]
#[activitystreams(CollectionPage)]
#[prop_refs]
pub collection_page_props: CollectionPageProperties,
/// Adds all valid ordered collection page properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ordered_collection_page_props: OrderedCollectionPageProperties,
}

View file

@ -412,4 +412,4 @@ pub fn context() -> crate::primitives::XsdAnyUri {
}
#[cfg(feature = "derive")]
pub use activitystreams_derive::{properties, PropRefs, UnitString};
pub use activitystreams_derive::{properties, wrapper_type, PropRefs, UnitString};

View file

@ -22,5 +22,5 @@ use crate::UnitString;
/// A Unit Struct that represents the string "Mention"
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Mention)]
#[unit_string(Mention)]
pub struct MentionType;

View file

@ -29,7 +29,8 @@ mod types;
#[cfg(feature = "types")]
pub use self::types::Mention;
use std::any::Any;
#[cfg(feature = "types")]
use crate::wrapper_type;
/// A Link is an indirect, qualified reference to a resource identified by a URL.
///
@ -39,57 +40,5 @@ use std::any::Any;
/// used, it establishes a qualified relation connecting the subject (the containing object) to the
/// resource identified by the href. Properties of the Link are properties of the reference as
/// opposed to properties of the resource.
#[typetag::serde(tag = "type")]
pub trait Link: std::fmt::Debug {
fn as_any(&self) -> &dyn Any;
fn as_any_mut(&mut self) -> &mut dyn Any;
fn duplicate(&self) -> Box<dyn Link>;
}
#[cfg(feature = "types")]
#[derive(Debug, serde::Deserialize, serde::Serialize)]
#[serde(transparent)]
pub struct LinkBox(pub Box<dyn Link>);
#[cfg(feature = "types")]
impl LinkBox {
pub fn is<T>(&self) -> bool
where
T: Link + 'static,
{
self.0.as_any().is::<T>()
}
pub fn downcast_ref<T>(&self) -> Option<&T>
where
T: Link + 'static,
{
self.0.as_any().downcast_ref()
}
pub fn downcast_mut<T>(&mut self) -> Option<&mut T>
where
T: Link + 'static,
{
self.0.as_any_mut().downcast_mut()
}
}
#[cfg(feature = "types")]
impl Clone for LinkBox {
fn clone(&self) -> Self {
LinkBox(self.0.duplicate())
}
}
#[cfg(feature = "types")]
impl<T> From<T> for LinkBox
where
T: Link + 'static,
{
fn from(t: T) -> Self {
LinkBox(Box::new(t))
}
}
#[cfg_attr(feature = "types", wrapper_type)]
pub trait Link: std::fmt::Debug {}

View file

@ -18,7 +18,7 @@
*/
use crate::{
link::{kind::*, properties::*, Link},
link::{kind::*, properties::*, Link, LinkBox},
PropRefs,
};
use serde::{Deserialize, Serialize};
@ -27,6 +27,7 @@ use serde::{Deserialize, Serialize};
/// A specialized Link that represents an @mention.
#[derive(Clone, Debug, Default, Deserialize, PropRefs, Serialize)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Link)]
pub struct Mention {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
@ -35,6 +36,6 @@ pub struct Mention {
/// Adds all valid link properties to this struct
#[serde(flatten)]
#[activitystreams(Link)]
#[prop_refs]
pub link_props: LinkProperties,
}

View file

@ -18,8 +18,8 @@
*/
use crate::{
object::{kind::*, properties::*},
Object, PropRefs,
object::{kind::*, properties::*, Object, ObjectBox},
PropRefs,
};
use serde::{Deserialize, Serialize};
@ -29,197 +29,209 @@ pub struct ApImageBox(pub Box<Image>);
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
pub struct Article {
#[serde(rename = "type")]
kind: ArticleType,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
pub struct Audio {
#[serde(rename = "type")]
kind: AudioType,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
pub struct Document {
#[serde(rename = "type")]
kind: DocumentType,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
pub struct Event {
#[serde(rename = "type")]
kind: EventType,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
pub struct Image {
#[serde(rename = "type")]
kind: ImageType,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
pub struct Note {
#[serde(rename = "type")]
kind: NoteType,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
pub struct Page {
#[serde(rename = "type")]
kind: PageType,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
pub struct Place {
#[serde(rename = "type")]
kind: PlaceType,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub place_props: PlaceProperties,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
pub struct Profile {
#[serde(rename = "type")]
kind: ProfileType,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub profile_props: ProfileProperties,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
pub struct Relationship {
#[serde(rename = "type")]
kind: RelationshipType,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub relationship_props: RelationshipProperties,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
pub struct Tombstone {
#[serde(rename = "type")]
kind: TombstoneType,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub tombstone_props: TombstoneProperties,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
pub struct Video {
#[serde(rename = "type")]
kind: VideoType,
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub ap_object_props: ApObjectProperties,
}

View file

@ -22,60 +22,60 @@ use crate::UnitString;
/// A Unit Struct that represents the string "Article"
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Article)]
#[unit_string(Article)]
pub struct ArticleType;
/// A Unit Struct that represents the string "Audio"
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Audio)]
#[unit_string(Audio)]
pub struct AudioType;
/// A Unit Struct that represents the string "Document"
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Document)]
#[unit_string(Document)]
pub struct DocumentType;
/// A Unit Struct that represents the string "Event"
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Event)]
#[unit_string(Event)]
pub struct EventType;
/// A Unit Struct that represents the string "Image"
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Image)]
#[unit_string(Image)]
pub struct ImageType;
/// A Unit Struct that represents the string "Note"
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Note)]
#[unit_string(Note)]
pub struct NoteType;
/// A Unit Struct that represents the string "Page"
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Page)]
#[unit_string(Page)]
pub struct PageType;
/// A Unit Struct that represents the string "Place"
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Place)]
#[unit_string(Place)]
pub struct PlaceType;
/// A Unit Struct that represents the string "Profile"
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Profile)]
#[unit_string(Profile)]
pub struct ProfileType;
/// A Unit Struct that represents the string "Relationship"
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Relationship)]
#[unit_string(Relationship)]
pub struct RelationshipType;
/// A Unit Struct that represents the string "Tombstone"
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Tombstone)]
#[unit_string(Tombstone)]
pub struct TombstoneType;
/// A Unit Struct that represents the string "Video"
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Video)]
#[unit_string(Video)]
pub struct VideoType;

View file

@ -28,73 +28,13 @@ pub mod properties;
#[cfg(feature = "types")]
pub mod streams;
use std::any::Any;
#[cfg(feature = "types")]
use crate::wrapper_type;
/// Describes an object of any kind.
///
/// The Object type serves as the base type for most of the other kinds of objects defined in the
/// Activity Vocabulary, including other Core types such as `Activity`, `IntransitiveActivity`,
/// `Collection` and `OrderedCollection`.
#[typetag::serde(tag = "type")]
pub trait Object: std::fmt::Debug {
/// Provide an as_any method to allow for borrowed downcasting.
///
/// This is useful since Objects can be deserialized generically via typetag
fn as_any(&self) -> &dyn Any;
/// Provide an as_any method to allow for mutably borrowed downcasting.
///
/// This is useful since Objects can be deserialized generically via typetag
fn as_any_mut(&mut self) -> &mut dyn Any;
/// Provide a duplicate method to allow for cloning type objects.
///
/// This is useful since Objects can be deserialized generically via typetag
fn duplicate(&self) -> Box<dyn Object>;
}
#[cfg(feature = "types")]
#[derive(Debug, serde::Deserialize, serde::Serialize)]
#[serde(transparent)]
pub struct ObjectBox(pub Box<dyn Object>);
#[cfg(feature = "types")]
impl ObjectBox {
pub fn is<T>(&self) -> bool
where
T: Object + 'static,
{
self.0.as_any().is::<T>()
}
pub fn downcast_ref<T>(&self) -> Option<&T>
where
T: Object + 'static,
{
self.0.as_any().downcast_ref()
}
pub fn downcast_mut<T>(&mut self) -> Option<&mut T>
where
T: Object + 'static,
{
self.0.as_any_mut().downcast_mut()
}
}
#[cfg(feature = "types")]
impl Clone for ObjectBox {
fn clone(&self) -> Self {
ObjectBox(self.0.duplicate())
}
}
#[cfg(feature = "types")]
impl<T> From<T> for ObjectBox
where
T: Object + 'static,
{
fn from(t: T) -> Self {
ObjectBox(Box::new(t))
}
}
#[cfg_attr(feature = "types", wrapper_type)]
pub trait Object: std::fmt::Debug {}

View file

@ -18,8 +18,8 @@
*/
use crate::{
object::{kind::*, properties::*},
Object, PropRefs,
object::{kind::*, properties::*, Object, ObjectBox},
PropRefs,
};
use serde::{Deserialize, Serialize};
@ -30,6 +30,7 @@ pub struct ImageBox(pub Box<Image>);
/// Represents any kind of multi-paragraph written work.
#[derive(Clone, Debug, Default, Deserialize, PropRefs, Serialize)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
pub struct Article {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
@ -38,13 +39,14 @@ pub struct Article {
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
}
/// Represents an audio document of any kind.
#[derive(Clone, Debug, Default, Deserialize, PropRefs, Serialize)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
pub struct Audio {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
@ -53,13 +55,14 @@ pub struct Audio {
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
}
/// Represents a document of any kind.
#[derive(Clone, Debug, Default, Deserialize, PropRefs, Serialize)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
pub struct Document {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
@ -68,13 +71,14 @@ pub struct Document {
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
}
/// Represents any kind of event.
#[derive(Clone, Debug, Default, Deserialize, PropRefs, Serialize)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
pub struct Event {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
@ -83,13 +87,14 @@ pub struct Event {
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
}
/// An image document of any kind
#[derive(Clone, Debug, Default, Deserialize, PropRefs, Serialize)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
pub struct Image {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
@ -98,13 +103,14 @@ pub struct Image {
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
}
/// Represents a short written work typically less than a single paragraph in length.
#[derive(Clone, Debug, Default, Deserialize, PropRefs, Serialize)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
pub struct Note {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
@ -113,13 +119,14 @@ pub struct Note {
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
}
/// Represents a Web Page.
#[derive(Clone, Debug, Default, Deserialize, PropRefs, Serialize)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
pub struct Page {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
@ -128,7 +135,7 @@ pub struct Page {
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
}
@ -152,6 +159,7 @@ pub struct Page {
/// MUST support the use of these properties.
#[derive(Clone, Debug, Default, Deserialize, PropRefs, Serialize)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
pub struct Place {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
@ -160,12 +168,12 @@ pub struct Place {
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid place properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub place: PlaceProperties,
}
@ -175,6 +183,7 @@ pub struct Place {
/// The `describes` property is used to reference the object being described by the profile.
#[derive(Clone, Debug, Default, Deserialize, PropRefs, Serialize)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
pub struct Profile {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
@ -183,12 +192,12 @@ pub struct Profile {
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid profile properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub profile: ProfileProperties,
}
@ -208,6 +217,7 @@ pub struct Profile {
/// and Jane have a mutual relationship.
#[derive(Clone, Debug, Default, Deserialize, PropRefs, Serialize)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
pub struct Relationship {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
@ -216,12 +226,12 @@ pub struct Relationship {
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid relationship properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub relationship: RelationshipProperties,
}
@ -231,6 +241,7 @@ pub struct Relationship {
/// it has been deleted.
#[derive(Clone, Debug, Default, Deserialize, PropRefs, Serialize)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
pub struct Tombstone {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
@ -239,18 +250,19 @@ pub struct Tombstone {
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
/// Adds all valid tombstone properties to this struct
#[serde(flatten)]
#[activitystreams(None)]
#[prop_refs]
pub tombstone_props: TombstoneProperties,
}
/// Represents a video document of any kind.
#[derive(Clone, Debug, Default, Deserialize, PropRefs, Serialize)]
#[serde(rename_all = "camelCase")]
#[prop_refs(Object)]
pub struct Video {
#[serde(rename = "type")]
#[serde(alias = "objectType")]
@ -259,7 +271,7 @@ pub struct Video {
/// Adds all valid object properties to this struct
#[serde(flatten)]
#[activitystreams(Object)]
#[prop_refs]
pub object_props: ObjectProperties,
}