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" repository = "https://git.asonix.dog/Aardwolf/activitystreams"
readme = "README.md" readme = "README.md"
keywords = ["activitystreams", "activitypub"] keywords = ["activitystreams", "activitypub"]
edition = "2018"
[dependencies] [dependencies]
activitystreams-traits = { version = "0.2", path = "activitystreams-traits" } 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" repository = "https://git.asonix.dog/Aardwolf/activitystreams"
readme = "README.md" readme = "README.md"
keywords = ["activitystreams", "activitypub"] keywords = ["activitystreams", "activitypub"]
edition = "2018"
[dependencies] [dependencies]
quote = "0.5" quote = "1.0"
syn = "0.13" syn = "1.0"
proc-macro2 = "0.3" proc-macro2 = "1.0"
[dev-dependencies] [dev-dependencies]
activitystreams-traits = { version = "0.2", path = "../activitystreams-traits" } activitystreams-traits = { version = "0.2", path = "../activitystreams-traits" }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -21,9 +21,8 @@
//! types //! types
use serde::{de::DeserializeOwned, ser::Serialize}; 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 /// Deserialize a `Value` into concrete type I
pub fn from_value<I>(item: &serde_json::Value) -> Result<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" repository = "https://git.asonix.dog/Aardwolf/activitystreams"
readme = "README.md" readme = "README.md"
keywords = ["activitystreams", "activitypub"] keywords = ["activitystreams", "activitypub"]
edition = "2018"
[dependencies] [dependencies]
activitystreams-derive = { version = "0.2", path = "../activitystreams-derive" } 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/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object}; use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{ use super::{
kind::AcceptType, kind::AcceptType,
properties::{AcceptProperties, ActivityProperties}, properties::{AcceptProperties, ActivityProperties},
ActivityExt, ActivityExt,
}; };
use object::{properties::ObjectProperties, ObjectExt}; use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor accepts the object. /// 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/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object}; use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{ use super::{
kind::AddType, kind::AddType,
properties::{ActivityProperties, AddProperties}, properties::{ActivityProperties, AddProperties},
ActivityExt, ActivityExt,
}; };
use object::{properties::ObjectProperties, ObjectExt}; use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor has added the object to the target. /// 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/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object}; use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{ use super::{
kind::MoveType, kind::MoveType,
properties::{ActivityProperties, MoveProperties}, properties::{ActivityProperties, MoveProperties},
ActivityExt, ActivityExt,
}; };
use object::{properties::ObjectProperties, ObjectExt}; use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor has moved object from origin to target. /// 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/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object}; use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{ use super::{
kind::AnnounceType, kind::AnnounceType,
properties::{ActivityProperties, AnnounceProperties}, properties::{ActivityProperties, AnnounceProperties},
ActivityExt, ActivityExt,
}; };
use object::{properties::ObjectProperties, ObjectExt}; use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor is calling the target's attention the object. /// 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/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, IntransitiveActivity, Object}; use activitystreams_traits::{Activity, IntransitiveActivity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{ use super::{
kind::ArriveType, kind::ArriveType,
properties::{ActivityProperties, ArriveProperties}, properties::{ActivityProperties, ArriveProperties},
ActivityExt, ActivityExt,
}; };
use object::{properties::ObjectProperties, ObjectExt}; use crate::object::{properties::ObjectProperties, ObjectExt};
/// An IntransitiveActivity that indicates that the actor has arrived at the location. /// 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/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object}; use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{ use super::{
kind::BlockType, kind::BlockType,
properties::{ActivityProperties, BlockProperties}, properties::{ActivityProperties, BlockProperties},
ActivityExt, ActivityExt,
}; };
use object::{properties::ObjectProperties, ObjectExt}; use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor is blocking the object. /// 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/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object}; use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{ use super::{
kind::CreateType, kind::CreateType,
properties::{ActivityProperties, CreateProperties}, properties::{ActivityProperties, CreateProperties},
ActivityExt, ActivityExt,
}; };
use object::{properties::ObjectProperties, ObjectExt}; use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor has created the object. /// Indicates that the actor has created the object.
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[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/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object}; use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{ use super::{
kind::DeleteType, kind::DeleteType,
properties::{ActivityProperties, DeleteProperties}, properties::{ActivityProperties, DeleteProperties},
ActivityExt, ActivityExt,
}; };
use object::{properties::ObjectProperties, ObjectExt}; use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor has deleted the object. /// 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/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object}; use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{ use super::{
kind::DislikeType, kind::DislikeType,
properties::{ActivityProperties, DislikeProperties}, properties::{ActivityProperties, DislikeProperties},
ActivityExt, ActivityExt,
}; };
use object::{properties::ObjectProperties, ObjectExt}; use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor dislikes the object. /// Indicates that the actor dislikes the object.
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[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/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object}; use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{ use super::{
kind::FlagType, kind::FlagType,
properties::{ActivityProperties, FlagProperties}, properties::{ActivityProperties, FlagProperties},
ActivityExt, ActivityExt,
}; };
use object::{properties::ObjectProperties, ObjectExt}; use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor is "flagging" the object. /// 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/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object}; use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{ use super::{
kind::FollowType, kind::FollowType,
properties::{ActivityProperties, FollowProperties}, properties::{ActivityProperties, FollowProperties},
ActivityExt, ActivityExt,
}; };
use object::{properties::ObjectProperties, ObjectExt}; use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor is "following" the object. /// 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/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object}; use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{ use super::{
kind::IgnoreType, kind::IgnoreType,
properties::{ActivityProperties, IgnoreProperties}, properties::{ActivityProperties, IgnoreProperties},
ActivityExt, ActivityExt,
}; };
use object::{properties::ObjectProperties, ObjectExt}; use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor is ignoring the object. /// 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/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object}; use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{ use super::{
kind::InviteType, kind::InviteType,
properties::{ActivityProperties, InviteProperties}, properties::{ActivityProperties, InviteProperties},
ActivityExt, 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 /// A specialization of Offer in which the actor is extending an invitation for the object to the
/// target. /// target.

View file

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

View file

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

View file

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

View file

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

View file

@ -17,14 +17,16 @@
* along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object}; use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{ use super::{
kind::OfferType, kind::OfferType,
properties::{ActivityProperties, OfferProperties}, properties::{ActivityProperties, OfferProperties},
ActivityExt, ActivityExt,
}; };
use object::{properties::ObjectProperties, ObjectExt}; use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor is offering the object. /// 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: //! To use these properties in your own types, you can flatten them into your struct with serde:
//! //!
//! ```rust //! ```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_traits::{Activity, Object};
//! use activitystreams_types::{ //! use activitystreams_types::{
//! activity::properties::ActivityProperties, //! activity::properties::ActivityProperties,
//! object::properties::ObjectProperties, //! object::properties::ObjectProperties,
//! }; //! };
//! use serde_derive::{Deserialize, Serialize};
//! //!
//! #[derive(Clone, Debug, Serialize, Deserialize)] //! #[derive(Clone, Debug, Serialize, Deserialize)]
//! #[serde(rename_all = "camelCase")] //! #[serde(rename_all = "camelCase")]
@ -58,8 +53,9 @@
//! # fn main() {} //! # fn main() {}
//! ``` //! ```
use activitystreams_derive::Properties;
use activitystreams_traits::{Link, Object}; 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 /// 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 /// 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/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, IntransitiveActivity, Object}; use activitystreams_traits::{Activity, IntransitiveActivity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{ use super::{
kind::QuestionType, kind::QuestionType,
properties::{ActivityProperties, QuestionProperties}, properties::{ActivityProperties, QuestionProperties},
ActivityExt, ActivityExt,
}; };
use object::{properties::ObjectProperties, ObjectExt}; use crate::object::{properties::ObjectProperties, ObjectExt};
/// Represents a question being asked. /// Represents a question being asked.
/// ///

View file

@ -17,14 +17,16 @@
* along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object}; use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{ use super::{
kind::ReadType, kind::ReadType,
properties::{ActivityProperties, ReadProperties}, properties::{ActivityProperties, ReadProperties},
ActivityExt, ActivityExt,
}; };
use object::{properties::ObjectProperties, ObjectExt}; use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor has read the object. /// Indicates that the actor has read the object.
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[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/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object}; use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{ use super::{
kind::RejectType, kind::RejectType,
properties::{ActivityProperties, RejectProperties}, properties::{ActivityProperties, RejectProperties},
ActivityExt, ActivityExt,
}; };
use object::{properties::ObjectProperties, ObjectExt}; use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor is rejecting the object. /// 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/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object}; use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{ use super::{
kind::RemoveType, kind::RemoveType,
properties::{ActivityProperties, RemoveProperties}, properties::{ActivityProperties, RemoveProperties},
ActivityExt, ActivityExt,
}; };
use object::{properties::ObjectProperties, ObjectExt}; use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor is removing the object. /// 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/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object}; use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{ use super::{
kind::TentativeAcceptType, kind::TentativeAcceptType,
properties::{ActivityProperties, TentativeAcceptProperties}, properties::{ActivityProperties, TentativeAcceptProperties},
ActivityExt, ActivityExt,
}; };
use object::{properties::ObjectProperties, ObjectExt}; use crate::object::{properties::ObjectProperties, ObjectExt};
/// A specialization of Accept indicating that the acceptance is tentative. /// A specialization of Accept indicating that the acceptance is tentative.
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[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/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object}; use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{ use super::{
kind::TentativeRejectType, kind::TentativeRejectType,
properties::{ActivityProperties, TentativeRejectProperties}, properties::{ActivityProperties, TentativeRejectProperties},
ActivityExt, ActivityExt,
}; };
use object::{properties::ObjectProperties, ObjectExt}; use crate::object::{properties::ObjectProperties, ObjectExt};
/// A specialization of Reject in which the rejection is considered tentative. /// A specialization of Reject in which the rejection is considered tentative.
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[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/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, IntransitiveActivity, Object}; use activitystreams_traits::{Activity, IntransitiveActivity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{ use super::{
kind::TravelType, kind::TravelType,
properties::{ActivityProperties, TravelProperties}, properties::{ActivityProperties, TravelProperties},
ActivityExt, ActivityExt,
}; };
use object::{properties::ObjectProperties, ObjectExt}; use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor is traveling to target from origin. /// 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/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object}; use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{ use super::{
kind::UndoType, kind::UndoType,
properties::{ActivityProperties, UndoProperties}, properties::{ActivityProperties, UndoProperties},
ActivityExt, ActivityExt,
}; };
use object::{properties::ObjectProperties, ObjectExt}; use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor is undoing the object. /// 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/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object}; use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{ use super::{
kind::UpdateType, kind::UpdateType,
properties::{ActivityProperties, UpdateProperties}, properties::{ActivityProperties, UpdateProperties},
ActivityExt, ActivityExt,
}; };
use object::{properties::ObjectProperties, ObjectExt}; use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor has updated the object. /// 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/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_derive::Properties;
use activitystreams_traits::{Activity, Object}; use activitystreams_traits::{Activity, Object};
use serde_derive::{Deserialize, Serialize};
use super::{ use super::{
kind::ViewType, kind::ViewType,
properties::{ActivityProperties, ViewProperties}, properties::{ActivityProperties, ViewProperties},
ActivityExt, ActivityExt,
}; };
use object::{properties::ObjectProperties, ObjectExt}; use crate::object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor has viewed the object. /// Indicates that the actor has viewed the object.
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]

View file

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

View file

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

View file

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

View file

@ -19,9 +19,11 @@
//! Namespace for Collection types //! Namespace for Collection types
use activitystreams_derive::Properties;
use activitystreams_traits::{Collection, CollectionPage, Object}; 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 kind;
pub mod properties; 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: //! To use these properties in your own types, you can flatten them into your struct with serde:
//! //!
//! ```rust //! ```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_traits::{Collection, Object};
//! use activitystreams_types::{ //! use activitystreams_types::{
//! collection::properties::CollectionProperties, //! collection::properties::CollectionProperties,
//! object::properties::ObjectProperties, //! object::properties::ObjectProperties,
//! }; //! };
//! use serde_derive::{Deserialize, Serialize};
//! //!
//! #[derive(Clone, Debug, Serialize, Deserialize)] //! #[derive(Clone, Debug, Serialize, Deserialize)]
//! #[serde(rename_all = "camelCase")] //! #[serde(rename_all = "camelCase")]
@ -56,8 +51,9 @@
//! # fn main() {} //! # fn main() {}
//! ``` //! ```
use activitystreams_derive::Properties;
use activitystreams_traits::{Collection, CollectionPage, Link, Object}; 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 /// `Collection` objects are a specialization of the base `Object` that serve as a container for
/// other `Objects` or `Links`. /// other `Objects` or `Links`.

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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