Merge branch 'asonix/2018-edition' of Aardwolf/activitystreams into master

This commit is contained in:
Arlo (Hyena) 2019-10-28 23:21:19 +00:00 committed by Gitea
commit 0673f48634
55 changed files with 188 additions and 200 deletions

View file

@ -7,6 +7,7 @@ authors = ["asonix <asonix@asonix.dog>"]
repository = "https://git.asonix.dog/Aardwolf/activitystreams"
readme = "README.md"
keywords = ["activitystreams", "activitypub"]
edition = "2018"
[dependencies]
activitystreams-traits = { version = "0.2", path = "activitystreams-traits" }

View file

@ -7,11 +7,12 @@ authors = ["asonix <asonix.dev@gmail.com>"]
repository = "https://git.asonix.dog/Aardwolf/activitystreams"
readme = "README.md"
keywords = ["activitystreams", "activitypub"]
edition = "2018"
[dependencies]
quote = "0.5"
syn = "0.13"
proc-macro2 = "0.3"
quote = "1.0"
syn = "1.0"
proc-macro2 = "1.0"
[dev-dependencies]
activitystreams-traits = { version = "0.2", path = "../activitystreams-traits" }

View file

@ -22,15 +22,9 @@
//! ## Examples
//!
//! ```rust
//! #[macro_use]
//! extern crate activitystreams_derive;
//! extern crate activitystreams_traits;
//! extern crate serde;
//! #[macro_use]
//! extern crate serde_derive;
//! extern crate serde_json;
//!
//! use activitystreams_derive::{Properties, UnitString};
//! use activitystreams_traits::{Link, Object};
//! use serde_derive::{Deserialize, Serialize};
//!
//! /// Using the UnitString derive macro
//! ///
@ -68,17 +62,14 @@
//! ```
extern crate proc_macro;
extern crate proc_macro2;
extern crate syn;
#[macro_use]
extern crate quote;
use proc_macro::TokenStream;
use proc_macro2::TokenTree;
use quote::Tokens;
use quote::quote;
use syn::{Attribute, Data, DeriveInput, Fields, Ident, Type};
use std::iter::FromIterator;
#[proc_macro_derive(UnitString, attributes(activitystreams))]
pub fn unit_string(input: TokenStream) -> TokenStream {
let input: DeriveInput = syn::parse(input).unwrap();
@ -93,16 +84,14 @@ pub fn unit_string(input: TokenStream) -> TokenStream {
.path
.segments
.last()
.map(|segment| {
let segment = segment.into_value();
segment.ident == Ident::new("activitystreams", segment.ident.span())
}).unwrap_or(false)
}).unwrap()
.map(|segment| segment.ident == Ident::new("activitystreams", segment.ident.span()))
.unwrap_or(false)
})
.unwrap()
.clone();
let value = from_value(attr);
let visitor_name = Ident::from(format!("{}Visitor", value));
let visitor_name = from_value(attr);
let value = format!("\"{}\"", visitor_name);
let serialize = quote! {
impl ::serde::ser::Serialize for #name {
@ -166,15 +155,16 @@ pub fn unit_string(input: TokenStream) -> TokenStream {
c.into()
}
fn from_value(attr: Attribute) -> String {
fn from_value(attr: Attribute) -> Ident {
let group = attr
.tts
.tokens
.clone()
.into_iter()
.filter_map(|token_tree| match token_tree {
TokenTree::Group(group) => Some(group),
_ => None,
}).next()
})
.next()
.unwrap();
group
@ -182,9 +172,10 @@ fn from_value(attr: Attribute) -> String {
.clone()
.into_iter()
.filter_map(|token_tree| match token_tree {
TokenTree::Term(term) => Some(term.as_str().to_owned()),
TokenTree::Ident(ident) => Some(ident),
_ => None,
}).next()
})
.next()
.unwrap()
}
@ -214,7 +205,6 @@ pub fn properties_derive(input: TokenStream) -> TokenStream {
.segments
.last()
.map(|segment| {
let segment = segment.into_value();
segment.ident == Ident::new("activitystreams", segment.ident.span())
})
.unwrap_or(false)
@ -228,7 +218,6 @@ pub fn properties_derive(input: TokenStream) -> TokenStream {
.segments
.last()
.map(|seg| {
let seg = seg.into_value();
seg.ident == Ident::new("Option", seg.ident.span())
})
.unwrap_or(false),
@ -240,7 +229,6 @@ pub fn properties_derive(input: TokenStream) -> TokenStream {
.segments
.last()
.map(|seg| {
let seg = seg.into_value();
seg.ident == Ident::new("Vec", seg.ident.span())
})
.unwrap_or(false),
@ -262,12 +250,11 @@ pub fn properties_derive(input: TokenStream) -> TokenStream {
variants(attr)
.into_iter()
.map(move |(variant, is_concrete)| {
let lower_variant = variant.to_lowercase();
let fn_name = Ident::from(format!("{}_{}", ident, lower_variant));
let fn_plural = Ident::from(format!("{}_{}_vec", ident, lower_variant));
let set_fn_name = Ident::from(format!("set_{}_{}", ident, lower_variant));
let set_fn_plural = Ident::from(format!("set_{}_{}_vec", ident, lower_variant));
let variant = Ident::from(variant);
let lower_variant = variant.to_string().to_lowercase();
let fn_name = Ident::new(&format!("{}_{}", ident, lower_variant), variant.span());
let fn_plural = Ident::new(&format!("{}_{}_vec", ident, lower_variant), variant.span());
let set_fn_name = Ident::new(&format!("set_{}_{}", ident, lower_variant), variant.span());
let set_fn_plural = Ident::new(&format!("set_{}_{}_vec", ident, lower_variant), variant.span());
if is_concrete {
if is_option {
@ -592,10 +579,9 @@ pub fn properties_derive(input: TokenStream) -> TokenStream {
})
});
let mut tokens = Tokens::new();
tokens.append_all(impls);
let tokens = proc_macro2::TokenStream::from_iter(impls);
let full = quote!{
let full = quote! {
impl #name {
#tokens
}
@ -604,15 +590,16 @@ pub fn properties_derive(input: TokenStream) -> TokenStream {
full.into()
}
fn variants(attr: Attribute) -> Vec<(String, bool)> {
fn variants(attr: Attribute) -> Vec<(Ident, bool)> {
let group = attr
.tts
.tokens
.clone()
.into_iter()
.filter_map(|token_tree| match token_tree {
TokenTree::Group(group) => Some(group),
_ => None,
}).next()
})
.next()
.unwrap();
let mut is_concrete = false;
@ -622,30 +609,32 @@ fn variants(attr: Attribute) -> Vec<(String, bool)> {
.clone()
.into_iter()
.filter_map(|token_tree| match token_tree {
TokenTree::Term(term) => {
is_concrete = term.as_str() == "concrete";
TokenTree::Ident(ident) => {
is_concrete = ident.to_string() == "concrete";
None
}
TokenTree::Group(group) => Some(group.stream().into_iter().filter_map(
move |token_tree| match token_tree {
TokenTree::Term(term) => Some((term.as_str().to_owned(), is_concrete)),
TokenTree::Ident(ident) => Some((ident, is_concrete)),
_ => None,
},
)),
_ => None,
}).flat_map(|i| i)
})
.flat_map(|i| i)
.collect()
}
fn is_functional(attr: Attribute) -> bool {
let group = attr
.tts
.tokens
.clone()
.into_iter()
.filter_map(|token_tree| match token_tree {
TokenTree::Group(group) => Some(group),
_ => None,
}).next()
})
.next()
.unwrap();
group
@ -653,7 +642,7 @@ fn is_functional(attr: Attribute) -> bool {
.clone()
.into_iter()
.any(|token_tree| match token_tree {
TokenTree::Term(term) => term.as_str() == "functional",
TokenTree::Ident(ident) => ident.to_string() == "functional",
_ => false,
})
}

View file

@ -7,6 +7,7 @@ authors = ["asonix <asonix.dev@gmail.com>"]
repository = "https://git.asonix.dog/Aardwolf/activitystreams"
readme = "README.md"
keywords = ["activitystreams", "activitypub"]
edition = "2018"
[dependencies]
serde = "1.0"

View file

@ -17,7 +17,7 @@
* along with ActivityStreams Traits. If not, see <http://www.gnu.org/licenses/>.
*/
use object::Object;
use crate::object::Object;
/// An Activity is a subtype of `Object` that describes some form of action that may happen, is
/// currently happening, or has already happened.

View file

@ -17,7 +17,7 @@
* along with ActivityStreams Traits. If not, see <http://www.gnu.org/licenses/>.
*/
use object::Object;
use crate::object::Object;
/// `Actor` types are `Object` types that are capable of performing activities.
///

View file

@ -17,7 +17,7 @@
* along with ActivityStreams Traits. If not, see <http://www.gnu.org/licenses/>.
*/
use object::Object;
use crate::object::Object;
/// A Collection is a subtype of `Object` that represents ordered or unordered sets of `Object` or
/// `Link` instances.

View file

@ -25,13 +25,8 @@
//! ## Examples
//!
//! ```rust
//! extern crate activitystreams_traits;
//! extern crate serde;
//! #[macro_use]
//! extern crate serde_derive;
//! extern crate serde_json;
//!
//! use activitystreams_traits::{Object, Actor};
//! use serde_derive::{Deserialize, Serialize};
//!
//! #[derive(Clone, Debug, Default, Deserialize, Serialize)]
//! #[serde(rename_all = "camelCase")]
@ -49,9 +44,6 @@
//! # fn main() {}
//! ```
extern crate serde;
extern crate serde_json;
mod activity;
mod actor;
mod collection;

View file

@ -21,9 +21,8 @@
//! types
use serde::{de::DeserializeOwned, ser::Serialize};
use serde_json;
use error::{Error, Result};
use crate::error::{Error, Result};
/// Deserialize a `Value` into concrete type I
pub fn from_value<I>(item: &serde_json::Value) -> Result<I>

View file

@ -7,6 +7,7 @@ authors = ["asonix <asonix@asonix.dog>"]
repository = "https://git.asonix.dog/Aardwolf/activitystreams"
readme = "README.md"
keywords = ["activitystreams", "activitypub"]
edition = "2018"
[dependencies]
activitystreams-derive = { version = "0.2", path = "../activitystreams-derive" }

View file

@ -17,14 +17,16 @@
* along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{
kind::AcceptType,
properties::{AcceptProperties, ActivityProperties},
ActivityExt,
};
use object::{properties::ObjectProperties, ObjectExt};
use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor accepts the object.
///

View file

@ -17,14 +17,16 @@
* along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{
kind::AddType,
properties::{ActivityProperties, AddProperties},
ActivityExt,
};
use object::{properties::ObjectProperties, ObjectExt};
use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor has added the object to the target.
///

View file

@ -17,14 +17,16 @@
* along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{
kind::MoveType,
properties::{ActivityProperties, MoveProperties},
ActivityExt,
};
use object::{properties::ObjectProperties, ObjectExt};
use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor has moved object from origin to target.
///

View file

@ -17,14 +17,16 @@
* along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{
kind::AnnounceType,
properties::{ActivityProperties, AnnounceProperties},
ActivityExt,
};
use object::{properties::ObjectProperties, ObjectExt};
use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor is calling the target's attention the object.
///

View file

@ -17,14 +17,16 @@
* along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, IntransitiveActivity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{
kind::ArriveType,
properties::{ActivityProperties, ArriveProperties},
ActivityExt,
};
use object::{properties::ObjectProperties, ObjectExt};
use crate::object::{properties::ObjectProperties, ObjectExt};
/// An IntransitiveActivity that indicates that the actor has arrived at the location.
///

View file

@ -17,14 +17,16 @@
* along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{
kind::BlockType,
properties::{ActivityProperties, BlockProperties},
ActivityExt,
};
use object::{properties::ObjectProperties, ObjectExt};
use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor is blocking the object.
///

View file

@ -17,14 +17,16 @@
* along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{
kind::CreateType,
properties::{ActivityProperties, CreateProperties},
ActivityExt,
};
use object::{properties::ObjectProperties, ObjectExt};
use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor has created the object.
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]

View file

@ -17,14 +17,16 @@
* along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{
kind::DeleteType,
properties::{ActivityProperties, DeleteProperties},
ActivityExt,
};
use object::{properties::ObjectProperties, ObjectExt};
use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor has deleted the object.
///

View file

@ -17,14 +17,16 @@
* along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{
kind::DislikeType,
properties::{ActivityProperties, DislikeProperties},
ActivityExt,
};
use object::{properties::ObjectProperties, ObjectExt};
use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor dislikes the object.
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]

View file

@ -17,14 +17,16 @@
* along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{
kind::FlagType,
properties::{ActivityProperties, FlagProperties},
ActivityExt,
};
use object::{properties::ObjectProperties, ObjectExt};
use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor is "flagging" the object.
///

View file

@ -17,14 +17,16 @@
* along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{
kind::FollowType,
properties::{ActivityProperties, FollowProperties},
ActivityExt,
};
use object::{properties::ObjectProperties, ObjectExt};
use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor is "following" the object.
///

View file

@ -17,14 +17,16 @@
* along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{
kind::IgnoreType,
properties::{ActivityProperties, IgnoreProperties},
ActivityExt,
};
use object::{properties::ObjectProperties, ObjectExt};
use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor is ignoring the object.
///

View file

@ -17,14 +17,16 @@
* along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{
kind::InviteType,
properties::{ActivityProperties, InviteProperties},
ActivityExt,
};
use object::{properties::ObjectProperties, ObjectExt};
use crate::object::{properties::ObjectProperties, ObjectExt};
/// A specialization of Offer in which the actor is extending an invitation for the object to the
/// target.

View file

@ -17,14 +17,16 @@
* along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{
kind::JoinType,
properties::{ActivityProperties, JoinProperties},
ActivityExt,
};
use object::{properties::ObjectProperties, ObjectExt};
use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor has joined the object.
///

View file

@ -19,6 +19,8 @@
//! Namespace for Unit Structs that serialize to strings
use activitystreams_derive::UnitString;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Accept)]
pub struct AcceptType;

View file

@ -17,14 +17,16 @@
* along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{
kind::LeaveType,
properties::{ActivityProperties, LeaveProperties},
ActivityExt,
};
use object::{properties::ObjectProperties, ObjectExt};
use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor has left the object.
///

View file

@ -17,14 +17,16 @@
* along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{
kind::LikeType,
properties::{ActivityProperties, LikeProperties},
ActivityExt,
};
use object::{properties::ObjectProperties, ObjectExt};
use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor likes, recommends or endorses the object.
///

View file

@ -17,14 +17,16 @@
* along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{
kind::ListenType,
properties::{ActivityProperties, ListenProperties},
ActivityExt,
};
use object::{properties::ObjectProperties, ObjectExt};
use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor has listened to the object.
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]

View file

@ -48,34 +48,12 @@ mod undo;
mod update;
mod view;
pub use self::accept::*;
pub use self::add::*;
pub use self::amove::*;
pub use self::announce::*;
pub use self::arrive::*;
pub use self::block::*;
pub use self::create::*;
pub use self::delete::*;
pub use self::dislike::*;
pub use self::flag::*;
pub use self::follow::*;
pub use self::ignore::*;
pub use self::invite::*;
pub use self::join::*;
pub use self::leave::*;
pub use self::like::*;
pub use self::listen::*;
pub use self::offer::*;
pub use self::question::*;
pub use self::read::*;
pub use self::reject::*;
pub use self::remove::*;
pub use self::tentative_accept::*;
pub use self::tentative_reject::*;
pub use self::travel::*;
pub use self::undo::*;
pub use self::update::*;
pub use self::view::*;
pub use self::{
accept::*, add::*, amove::*, announce::*, arrive::*, block::*, create::*, delete::*,
dislike::*, flag::*, follow::*, ignore::*, invite::*, join::*, leave::*, like::*, listen::*,
offer::*, question::*, read::*, reject::*, remove::*, tentative_accept::*, tentative_reject::*,
travel::*, undo::*, update::*, view::*,
};
use activitystreams_traits::Activity;

View file

@ -17,14 +17,16 @@
* along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{
kind::OfferType,
properties::{ActivityProperties, OfferProperties},
ActivityExt,
};
use object::{properties::ObjectProperties, ObjectExt};
use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor is offering the object.
///

View file

@ -22,17 +22,12 @@
//! To use these properties in your own types, you can flatten them into your struct with serde:
//!
//! ```rust
//! extern crate activitystreams_traits;
//! extern crate activitystreams_types;
//! extern crate serde;
//! #[macro_use]
//! extern crate serde_derive;
//!
//! use activitystreams_traits::{Activity, Object};
//! use activitystreams_types::{
//! activity::properties::ActivityProperties,
//! object::properties::ObjectProperties,
//! };
//! use serde_derive::{Deserialize, Serialize};
//!
//! #[derive(Clone, Debug, Serialize, Deserialize)]
//! #[serde(rename_all = "camelCase")]
@ -58,8 +53,9 @@
//! # fn main() {}
//! ```
use activitystreams_derive::Properties;
use activitystreams_traits::{Link, Object};
use serde_json;
use serde_derive::{Deserialize, Serialize};
/// Activity objects are specializations of the base Object type that provide information about
/// actions that have either already occurred, are in the process of occurring, or may occur in the

View file

@ -17,14 +17,16 @@
* along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, IntransitiveActivity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{
kind::QuestionType,
properties::{ActivityProperties, QuestionProperties},
ActivityExt,
};
use object::{properties::ObjectProperties, ObjectExt};
use crate::object::{properties::ObjectProperties, ObjectExt};
/// Represents a question being asked.
///

View file

@ -17,14 +17,16 @@
* along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{
kind::ReadType,
properties::{ActivityProperties, ReadProperties},
ActivityExt,
};
use object::{properties::ObjectProperties, ObjectExt};
use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor has read the object.
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]

View file

@ -17,14 +17,16 @@
* along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{
kind::RejectType,
properties::{ActivityProperties, RejectProperties},
ActivityExt,
};
use object::{properties::ObjectProperties, ObjectExt};
use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor is rejecting the object.
///

View file

@ -17,14 +17,16 @@
* along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{
kind::RemoveType,
properties::{ActivityProperties, RemoveProperties},
ActivityExt,
};
use object::{properties::ObjectProperties, ObjectExt};
use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor is removing the object.
///

View file

@ -17,14 +17,16 @@
* along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{
kind::TentativeAcceptType,
properties::{ActivityProperties, TentativeAcceptProperties},
ActivityExt,
};
use object::{properties::ObjectProperties, ObjectExt};
use crate::object::{properties::ObjectProperties, ObjectExt};
/// A specialization of Accept indicating that the acceptance is tentative.
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]

View file

@ -17,14 +17,16 @@
* along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{
kind::TentativeRejectType,
properties::{ActivityProperties, TentativeRejectProperties},
ActivityExt,
};
use object::{properties::ObjectProperties, ObjectExt};
use crate::object::{properties::ObjectProperties, ObjectExt};
/// A specialization of Reject in which the rejection is considered tentative.
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]

View file

@ -17,14 +17,16 @@
* along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, IntransitiveActivity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{
kind::TravelType,
properties::{ActivityProperties, TravelProperties},
ActivityExt,
};
use object::{properties::ObjectProperties, ObjectExt};
use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor is traveling to target from origin.
///

View file

@ -17,14 +17,16 @@
* along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{
kind::UndoType,
properties::{ActivityProperties, UndoProperties},
ActivityExt,
};
use object::{properties::ObjectProperties, ObjectExt};
use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor is undoing the object.
///

View file

@ -17,14 +17,16 @@
* along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{
kind::UpdateType,
properties::{ActivityProperties, UpdateProperties},
ActivityExt,
};
use object::{properties::ObjectProperties, ObjectExt};
use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor has updated the object.
///

View file

@ -17,14 +17,16 @@
* along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{
kind::ViewType,
properties::{ActivityProperties, ViewProperties},
ActivityExt,
};
use object::{properties::ObjectProperties, ObjectExt};
use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor has viewed the object.
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]

View file

@ -18,6 +18,7 @@
*/
//! Namespace for Unit Structs that serialize to strings
use activitystreams_derive::UnitString;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Application)]

View file

@ -20,8 +20,9 @@
//! Namespace for Actor types
use activitystreams_traits::{Actor, Object};
use serde_derive::{Deserialize, Serialize};
use object::{properties::ObjectProperties, ObjectExt};
use crate::object::{properties::ObjectProperties, ObjectExt};
pub mod kind;
use self::kind::*;

View file

@ -18,6 +18,7 @@
*/
//! Namespace for Unit Structs that serialize to strings
use activitystreams_derive::UnitString;
#[derive(Clone, Debug, Default, UnitString)]
#[activitystreams(Collection)]

View file

@ -19,9 +19,11 @@
//! Namespace for Collection types
use activitystreams_derive::Properties;
use activitystreams_traits::{Collection, CollectionPage, Object};
use serde_derive::{Deserialize, Serialize};
use object::{properties::ObjectProperties, ObjectExt};
use crate::object::{properties::ObjectProperties, ObjectExt};
pub mod kind;
pub mod properties;

View file

@ -22,17 +22,12 @@
//! To use these properties in your own types, you can flatten them into your struct with serde:
//!
//! ```rust
//! extern crate activitystreams_traits;
//! extern crate activitystreams_types;
//! extern crate serde;
//! #[macro_use]
//! extern crate serde_derive;
//!
//! use activitystreams_traits::{Collection, Object};
//! use activitystreams_types::{
//! collection::properties::CollectionProperties,
//! object::properties::ObjectProperties,
//! };
//! use serde_derive::{Deserialize, Serialize};
//!
//! #[derive(Clone, Debug, Serialize, Deserialize)]
//! #[serde(rename_all = "camelCase")]
@ -56,8 +51,9 @@
//! # fn main() {}
//! ```
use activitystreams_derive::Properties;
use activitystreams_traits::{Collection, CollectionPage, Link, Object};
use serde_json;
use serde_derive::{Deserialize, Serialize};
/// `Collection` objects are a specialization of the base `Object` that serve as a container for
/// other `Objects` or `Links`.

View file

@ -19,11 +19,12 @@
//! A collection of simple types for extending the ActivityStreams Types base types
use serde::{de::DeserializeOwned, ser::Serialize};
use serde::{de::DeserializeOwned, ser};
use activitystreams_traits::{
Activity, Actor, Collection, CollectionPage, IntransitiveActivity, Link, Object,
};
use serde_derive::{Deserialize, Serialize};
/// A custom type extending Link
///
@ -64,7 +65,7 @@ impl<C, L: Link> CustomLink<C, L> {
impl<C, L> Link for CustomLink<C, L>
where
C: DeserializeOwned + Serialize,
C: DeserializeOwned + ser::Serialize,
L: Link,
{
}
@ -114,33 +115,37 @@ impl<C, O: Object> CustomObject<C, O> {
impl<C, O> Object for CustomObject<C, O>
where
C: DeserializeOwned + Serialize,
C: DeserializeOwned + ser::Serialize,
O: Object,
{
}
impl<C, O> Actor for CustomObject<C, O>
where
C: DeserializeOwned + Serialize,
C: DeserializeOwned + ser::Serialize,
O: Actor,
{
}
impl<C, O> Collection for CustomObject<C, O>
where
C: DeserializeOwned + Serialize,
C: DeserializeOwned + ser::Serialize,
O: Collection,
{}
{
}
impl<C, O> CollectionPage for CustomObject<C, O>
where
C: DeserializeOwned + Serialize,
C: DeserializeOwned + ser::Serialize,
O: CollectionPage,
{}
{
}
impl<C, O> Activity for CustomObject<C, O>
where
C: DeserializeOwned + Serialize,
C: DeserializeOwned + ser::Serialize,
O: Activity,
{}
{
}
impl<C, O> IntransitiveActivity for CustomObject<C, O>
where
C: DeserializeOwned + Serialize,
C: DeserializeOwned + ser::Serialize,
O: IntransitiveActivity,
{}
{
}

View file

@ -23,10 +23,6 @@
//!
//! ## Example Usage
//! ```rust
//! extern crate activitystreams_types;
//! extern crate anyhow;
//! extern crate serde_json;
//!
//! use activitystreams_types::{context, link::Mention};
//!
//! fn run() -> Result<(), anyhow::Error> {
@ -46,15 +42,7 @@
//! # }
//! ```
#[macro_use]
extern crate activitystreams_derive;
extern crate activitystreams_traits;
extern crate chrono;
extern crate mime;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
use serde_derive::{Deserialize, Serialize};
/// Define a simple wrapper around a string for this crate's main Context type
#[derive(Clone, Debug, Deserialize, Serialize)]

View file

@ -18,6 +18,7 @@
*/
//! Namespace for Unit Structs that serialize to strings
use activitystreams_derive::UnitString;
/// A Unit Struct that represents the string "Mention"
#[derive(Clone, Debug, Default, UnitString)]

View file

@ -20,6 +20,7 @@
//! Namespace for Link types
use activitystreams_traits::Link;
use serde_derive::{Deserialize, Serialize};
pub mod kind;
pub mod properties;

View file

@ -22,14 +22,9 @@
//! To use these properties in your own types, you can flatten them into your struct with serde:
//!
//! ```rust
//! extern crate activitystreams_traits;
//! extern crate activitystreams_types;
//! extern crate serde;
//! #[macro_use]
//! extern crate serde_derive;
//!
//! use activitystreams_traits::Link;
//! use activitystreams_types::link::properties::LinkProperties;
//! use serde_derive::{Deserialize, Serialize};
//!
//! #[derive(Clone, Debug, Serialize, Deserialize)]
//! #[serde(rename_all = "camelCase")]
@ -49,9 +44,9 @@
//! # fn main() {}
//! ```
use activitystreams_derive::Properties;
use activitystreams_traits::{Error, Link, Object, Result};
use mime;
use serde_json;
use serde_derive::{Deserialize, Serialize};
/// Define all the properties of the Object base type as described by the Activity Streams
/// vocabulary.

View file

@ -18,6 +18,7 @@
*/
//! Namespace for Unit Structs that serialize to strings
use activitystreams_derive::UnitString;
/// A Unit Struct that represents the string "Article"
#[derive(Clone, Debug, Default, UnitString)]

View file

@ -19,7 +19,9 @@
//! Namespace for Object types
use activitystreams_derive::Properties;
use activitystreams_traits::Object;
use serde_derive::{Deserialize, Serialize};
pub mod kind;
pub mod properties;

View file

@ -22,14 +22,9 @@
//! To use these properties in your own types, you can flatten them into your struct with serde:
//!
//! ```rust
//! extern crate activitystreams_traits;
//! extern crate activitystreams_types;
//! extern crate serde;
//! #[macro_use]
//! extern crate serde_derive;
//!
//! use activitystreams_traits::Object;
//! use activitystreams_types::object::properties::ObjectProperties;
//! use serde_derive::{Deserialize, Serialize};
//!
//! #[derive(Clone, Debug, Serialize, Deserialize)]
//! #[serde(rename_all = "camelCase")]
@ -49,12 +44,12 @@
//! # fn main() {}
//! ```
use activitystreams_derive::Properties;
use activitystreams_traits::{Collection, Error, Link, Object, Result};
use chrono::{offset::Utc, DateTime};
use mime;
use serde_json;
use serde_derive::{Deserialize, Serialize};
use object::Image;
use crate::object::Image;
/// Alias chrono::DateTime<Utc> for use in derive macros
pub type UtcTime = DateTime<Utc>;

View file

@ -26,14 +26,8 @@
//! ### Basic
//!
//! ```rust
//! extern crate activitystreams;
//! extern crate anyhow;
//! extern crate serde;
//! #[macro_use]
//! extern crate serde_derive;
//! extern crate serde_json;
//!
//! use activitystreams::{context, Object, Actor, object::Profile};
//! use serde_derive::{Deserialize, Serialize};
//!
//! #[derive(Clone, Debug, Default, Deserialize, Serialize)]
//! #[serde(rename_all = "camelCase")]
@ -74,18 +68,10 @@
//! ### Advanced
//!
//! ```rust
//! #[macro_use]
//! extern crate activitystreams_derive;
//! extern crate activitystreams_traits;
//! extern crate activitystreams_types;
//! extern crate anyhow;
//! extern crate serde;
//! #[macro_use]
//! extern crate serde_derive;
//! extern crate serde_json;
//!
//! use activitystreams_derive::{Properties, UnitString};
//! use activitystreams_traits::{Link, Object};
//! use activitystreams_types::{CustomLink, link::Mention};
//! use serde_derive::{Deserialize, Serialize};
//!
//! /// Using the UnitString derive macro
//! ///
@ -136,9 +122,6 @@
//! # }
//! ```
extern crate activitystreams_traits;
extern crate activitystreams_types;
pub mod activity;
pub mod actor;
pub mod collection;