diff --git a/Cargo.toml b/Cargo.toml index b3e1b2a..a5b1826 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "activitystreams" -description = "Derive macros for activitystreams" +description = "Activity Streams in Rust" version = "0.1.0" license = "GPL-3.0" authors = ["asonix "] @@ -8,10 +8,12 @@ repository = "https://github.com/asonix/activitystreams" keywords = ["activitystreams", "activitypub"] [dependencies] -activitystreams-derive = { version = "0.1", path = "activitystreams-derive" } -chrono = { version = "0.4", features = ["serde"] } -failure = "0.1" -mime = "0.3" -serde = "1.0" -serde_derive = "1.0" -serde_json = "1.0" +activitystreams-traits = { version = "0.1", path = "activitystreams-traits" } +activitystreams-types = { version = "0.1", path = "activitystreams-types" } + +[workspace] +members = [ + "activitystreams-derive", + "activitystreams-traits", + "activitystreams-types", +] diff --git a/activitystreams-derive/src/lib.rs b/activitystreams-derive/src/lib.rs index c33ba9e..171a696 100644 --- a/activitystreams-derive/src/lib.rs +++ b/activitystreams-derive/src/lib.rs @@ -224,7 +224,7 @@ pub fn properties_derive(input: TokenStream) -> TokenStream { if is_concrete { if is_option { - let single = quote! { + let single_1 = quote! { /// Retrieve a value from the given struct /// /// This method deserializes the item from JSON, so be wary of using @@ -232,28 +232,33 @@ pub fn properties_derive(input: TokenStream) -> TokenStream { /// /// Possible errors from this method are `Error::NotFound` and /// `Error::Deserialize` - pub fn #fn_name(&self) -> ::error::Result<#variant> { - ::properties::from_item(&self.#ident) + pub fn #fn_name(&self) -> ::activitystreams_traits::Result<#variant> { + ::activitystreams_traits::properties::from_item(&self.#ident) } + }; + let single_2 = quote! { /// Set a value in the given struct /// /// This method serializes the item to JSON, so be wary of using this a /// lot. /// /// Possible errors from this method are `Error::Serialize` - pub fn #set_fn_name(&mut self, item: #variant) -> ::error::Result<()> { - self.#ident = ::properties::to_item(item)?; + pub fn #set_fn_name(&mut self, item: #variant) -> ::activitystreams_traits::Result<()> { + self.#ident = ::activitystreams_traits::properties::to_item(item)?; Ok(()) } }; + let single = quote! { + #single_1 + #single_2 + }; + if is_functional { single } else { - quote! { - #single - + let plural_1 = quote! { /// Retrieve many values from the given struct /// /// This method deserializes the item from JSON, so be wary of using @@ -261,44 +266,59 @@ pub fn properties_derive(input: TokenStream) -> TokenStream { /// /// Possible errors from this method are `Error::NotFound` and /// `Error::Deserialize` - pub fn #fn_plural(&self) -> ::error::Result> { - ::properties::from_item(&self.#ident) + pub fn #fn_plural(&self) -> ::activitystreams_traits::Result> { + ::activitystreams_traits::properties::from_item(&self.#ident) } + }; + let plural_2 = quote! { /// Set many values in the given struct /// /// This method serializes the item to JSON, so be wary of using /// this a lot. /// /// Possible errors from this method are `Error::Serialize` - pub fn #set_fn_plural(&mut self, item: Vec<#variant>) -> ::error::Result<()> { - self.#ident = ::properties::to_item(item)?; + pub fn #set_fn_plural(&mut self, item: Vec<#variant>) -> ::activitystreams_traits::Result<()> { + self.#ident = ::activitystreams_traits::properties::to_item(item)?; Ok(()) } + }; + + quote! { + #single + #plural_1 + #plural_2 } } } else if is_vec { - quote! { + let single_1 = quote! { /// Retrieve many values from the given struct /// /// This method deserializes the item from JSON, so be wary of using /// this a lot. /// /// Possible errors from this method are `Error::Deserialize` - pub fn #fn_name(&self) -> ::error::Result> { - ::properties::from_vec(&self.#ident) + pub fn #fn_name(&self) -> ::activitystreams_traits::Result> { + ::activitystreams_traits::properties::from_vec(&self.#ident) } + }; + let single_2 = quote! { /// Set many values in the given struct /// /// This method serializes the item to JSON, so be wary of using /// this a lot. /// /// Possible errors from this method are `Error::Serialize` - pub fn #set_fn_name(&mut self, item: Vec<#variant>>) -> ::error::Result<()> { - self.#ident = ::properties::to_vec(item)?; + pub fn #set_fn_name(&mut self, item: Vec<#variant>>) -> ::activitystreams_traits::Result<()> { + self.#ident = ::activitystreams_traits::properties::to_vec(item)?; Ok(()) } + }; + + quote! { + #single_1 + #single_2 } } else { let single = quote! { @@ -308,8 +328,8 @@ pub fn properties_derive(input: TokenStream) -> TokenStream { /// this a lot. /// /// Possible errors from this method are `Error::Deserialize` - pub fn #fn_name(&self) -> ::error::Result<#variant> { - ::properties::from_value(&self.#ident) + pub fn #fn_name(&self) -> ::activitystreams_traits::Result<#variant> { + ::activitystreams_traits::properties::from_value(&self.#ident) } /// Set a value in the given struct @@ -318,8 +338,8 @@ pub fn properties_derive(input: TokenStream) -> TokenStream { /// lot. /// /// Possible errors from this method are `Error::Serialize` - pub fn #set_fn_name(&mut self, item: #variant) -> ::error::Result<()> { - self.#ident = ::properties::to_value(item)?; + pub fn #set_fn_name(&mut self, item: #variant) -> ::activitystreams_traits::Result<()> { + self.#ident = ::activitystreams_traits::properties::to_value(item)?; Ok(()) } }; @@ -327,29 +347,35 @@ pub fn properties_derive(input: TokenStream) -> TokenStream { if is_functional { single } else { - quote! { - #single - + let plural_1 = quote! { /// Retrieve many values from the given struct /// /// This method deserializes the item from JSON, so be wary of using /// this a lot. /// /// Possible errors from this method are `Error::Deserialize` - pub fn #fn_plural(&self) -> ::error::Result> { - ::properties::from_value(&self.#ident) + pub fn #fn_plural(&self) -> ::activitystreams_traits::Result> { + ::activitystreams_traits::properties::from_value(&self.#ident) } + }; + let plural_2 = quote! { /// Set many values in the given struct /// /// This method serializes the item to JSON, so be wary of using this /// a lot. /// /// Possible errors from this method are `Error::Serialize` - pub #set_fn_plural(&mut self, item: Vec<#variant>) -> ::error::Result<()> { - self.#ident = ::properties::to_value(item)?; + pub #set_fn_plural(&mut self, item: Vec<#variant>) -> ::activitystreams_traits::Result<()> { + self.#ident = ::activitystreams_traits::properties::to_value(item)?; Ok(()) } + }; + + quote! { + #single + #plural_1 + #plural_2 } } } @@ -362,8 +388,8 @@ pub fn properties_derive(input: TokenStream) -> TokenStream { /// /// Possible errors from this method are `Error::NotFound` and /// `Error::Deserialize` - pub fn #fn_name(&self) -> ::error::Result { - ::properties::from_item(&self.#ident) + pub fn #fn_name(&self) -> ::activitystreams_traits::Result { + ::activitystreams_traits::properties::from_item(&self.#ident) } }; @@ -374,8 +400,8 @@ pub fn properties_derive(input: TokenStream) -> TokenStream { /// lot. /// /// Possible errors from this method are `Error::Serialize` - pub fn #set_fn_name(&mut self, item: T) -> ::error::Result<()> { - self.#ident = ::properties::to_item(item)?; + pub fn #set_fn_name(&mut self, item: T) -> ::activitystreams_traits::Result<()> { + self.#ident = ::activitystreams_traits::properties::to_item(item)?; Ok(()) } }; @@ -396,8 +422,8 @@ pub fn properties_derive(input: TokenStream) -> TokenStream { /// /// Possible errors from this method are `Error::NotFound` and /// `Error::Deserialize` - pub fn #fn_plural(&self) -> ::error::Result> { - ::properties::from_item(&self.#ident) + pub fn #fn_plural(&self) -> ::activitystreams_traits::Result> { + ::activitystreams_traits::properties::from_item(&self.#ident) } }; @@ -408,8 +434,8 @@ pub fn properties_derive(input: TokenStream) -> TokenStream { /// this a lot. /// /// Possible errors from this method are `Error::Serialize` - pub fn #set_fn_plural(&mut self, item: Vec) -> ::error::Result<()> { - self.#ident = ::properties::to_item(item)?; + pub fn #set_fn_plural(&mut self, item: Vec) -> ::activitystreams_traits::Result<()> { + self.#ident = ::activitystreams_traits::properties::to_item(item)?; Ok(()) } }; @@ -428,8 +454,8 @@ pub fn properties_derive(input: TokenStream) -> TokenStream { /// this a lot. /// /// Possible errors from this method are `Error::Deserialize` - pub fn #fn_name(&self) -> ::error::Result> { - ::properties::from_vec(&self.#ident) + pub fn #fn_name(&self) -> ::activitystreams_traits::Result> { + ::activitystreams_traits::properties::from_vec(&self.#ident) } }; @@ -440,8 +466,8 @@ pub fn properties_derive(input: TokenStream) -> TokenStream { /// this a lot. /// /// Possible errors from this method are `Error::Serialize` - pub fn #set_fn_name(&mut self, item: Vec) -> ::error::Result<()> { - self.#ident = ::properties::to_vec(item)?; + pub fn #set_fn_name(&mut self, item: Vec) -> ::activitystreams_traits::Result<()> { + self.#ident = ::activitystreams_traits::properties::to_vec(item)?; Ok(()) } }; @@ -458,8 +484,8 @@ pub fn properties_derive(input: TokenStream) -> TokenStream { /// this a lot. /// /// Possible errors from this method are `Error::Deserialize` - pub fn #fn_name(&self) -> ::error::Result { - ::properties::from_value(&self.#ident) + pub fn #fn_name(&self) -> ::activitystreams_traits::Result { + ::activitystreams_traits::properties::from_value(&self.#ident) } }; @@ -470,8 +496,8 @@ pub fn properties_derive(input: TokenStream) -> TokenStream { /// lot. /// /// Possible errors from this method are `Error::Serialize` - pub fn #set_fn_name(&mut self, item: T) -> ::error::Result<()> { - self.#ident = ::properties::to_value(item)?; + pub fn #set_fn_name(&mut self, item: T) -> ::activitystreams_traits::Result<()> { + self.#ident = ::activitystreams_traits::properties::to_value(item)?; Ok(()) } }; @@ -491,8 +517,8 @@ pub fn properties_derive(input: TokenStream) -> TokenStream { /// this a lot. /// /// Possible errors from this method are `Error::Deserialize` - pub fn #fn_plural(&self) -> ::error::Result> { - ::properties::from_value(&self.#ident) + pub fn #fn_plural(&self) -> ::activitystreams_traits::Result> { + ::activitystreams_traits::properties::from_value(&self.#ident) } }; @@ -503,8 +529,8 @@ pub fn properties_derive(input: TokenStream) -> TokenStream { /// a lot. /// /// Possible errors from this method are `Error::Serialize` - pub fn #set_fn_plural(&mut self, item: Vec) -> ::error::Result<()> { - self.#ident = ::properties::to_value(item)?; + pub fn #set_fn_plural(&mut self, item: Vec) -> ::activitystreams_traits::Result<()> { + self.#ident = ::activitystreams_traits::properties::to_value(item)?; Ok(()) } }; diff --git a/activitystreams-traits/.gitignore b/activitystreams-traits/.gitignore new file mode 100644 index 0000000..6936990 --- /dev/null +++ b/activitystreams-traits/.gitignore @@ -0,0 +1,3 @@ +/target +**/*.rs.bk +Cargo.lock diff --git a/ACKNOWLEDGEMENTS b/activitystreams-traits/ACKNOWLEDGEMENTS similarity index 100% rename from ACKNOWLEDGEMENTS rename to activitystreams-traits/ACKNOWLEDGEMENTS diff --git a/activitystreams-traits/Cargo.toml b/activitystreams-traits/Cargo.toml new file mode 100644 index 0000000..195b0e0 --- /dev/null +++ b/activitystreams-traits/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "activitystreams-traits" +description = "Traits for ActivityStreams objects" +version = "0.1.0" +license = "GPL-3.0" +authors = ["asonix "] +repository = "https://github.com/asonix/activitystreams" +keywords = ["activitystreams", "activitypub"] + +[dependencies] +failure = "0.1" +serde = "1.0" +serde_json = "1.0" diff --git a/LICENSE b/activitystreams-traits/LICENSE similarity index 100% rename from LICENSE rename to activitystreams-traits/LICENSE diff --git a/activitystreams-traits/src/activity.rs b/activitystreams-traits/src/activity.rs new file mode 100644 index 0000000..6c96d8d --- /dev/null +++ b/activitystreams-traits/src/activity.rs @@ -0,0 +1,23 @@ +/* + * This file is part of ActivityStreams Traits. + * + * Copyright © 2018 Riley Trautman + * + * ActivityStreams Traits 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 Traits 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 Traits. If not, see . + */ + +use object::Object; + +pub trait Activity: Object {} +pub trait IntransitiveActivity: Activity {} diff --git a/activitystreams-traits/src/actor.rs b/activitystreams-traits/src/actor.rs new file mode 100644 index 0000000..6935b46 --- /dev/null +++ b/activitystreams-traits/src/actor.rs @@ -0,0 +1,41 @@ +/* + * This file is part of ActivityStreams Traits. + * + * Copyright © 2018 Riley Trautman + * + * ActivityStreams Traits 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 Traits 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 Traits. If not, see . + */ + +use object::Object; + +/// `Actor` types are `Object` types that are capable of performing activities. +/// +/// This specification intentionally defines `Actors` in only the most generalized way, stopping +/// short of defining semantically specific properties for each. All Actor objects are +/// specializations of `Object` and inherit all of the core properties common to all Objects. +/// External vocabularies can be used to express additional detail not covered by the Activity +/// Vocabulary. VCard [[vcard-rdf](https://www.w3.org/TR/vcard-rdf/) SHOULD be used to provide +/// additional metadata for `Person`, `Group`, and `Organization` instances. +/// +/// While implementations are free to introduce new types of Actors beyond those defined by the +/// Activity Vocabulary, interoperability issues can arise when applications rely too much on +/// extension types that are not recognized by other implementations. Care should be taken to not +/// unduly overlap with or duplicate the existing `Actor` types. +/// +/// When an implementation uses an extension type that overlaps with a core vocabulary type, the +/// implementation MUST also specify the core vocabulary type. For instance, some vocabularies +/// (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`. +pub trait Actor: Object {} diff --git a/activitystreams-traits/src/collection.rs b/activitystreams-traits/src/collection.rs new file mode 100644 index 0000000..f2cc372 --- /dev/null +++ b/activitystreams-traits/src/collection.rs @@ -0,0 +1,27 @@ +/* + * This file is part of ActivityStreams Traits. + * + * Copyright © 2018 Riley Trautman + * + * ActivityStreams Traits 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 Traits 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 Traits. If not, see . + */ + +use object::Object; + +/// A Collection is a subtype of `Object` that represents ordered or unordered sets of `Object` or +/// `Link` instances. +pub trait Collection: Object {} + +/// Used to represent distinct subsets of items from a Collection. +pub trait CollectionPage: Collection {} diff --git a/activitystreams-traits/src/error.rs b/activitystreams-traits/src/error.rs new file mode 100644 index 0000000..4da9225 --- /dev/null +++ b/activitystreams-traits/src/error.rs @@ -0,0 +1,40 @@ +/* + * This file is part of ActivityStreams Traits. + * + * Copyright © 2018 Riley Trautman + * + * ActivityStreams Traits 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 Traits 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 Traits. If not, see . + */ + +use std::result; + +/// The Error type +#[derive(Copy, Clone, Debug, Fail)] +pub enum Error { + /// This error occurs when an Activity Streams type does not contain a requested value + #[fail(display = "Key not present")] + NotFound, + + /// This error occurs when a requested value could not be deserialized into the requested type + #[fail(display = "Failed to deserialize data as requested type")] + Deserialize, + + /// This error occurs when a provided item could not be serialized into an Activity Streams + /// type + #[fail(display = "Failed to serialize data")] + Serialize, +} + +/// An alias for Result +pub type Result = result::Result; diff --git a/activitystreams-traits/src/lib.rs b/activitystreams-traits/src/lib.rs new file mode 100644 index 0000000..fde30b2 --- /dev/null +++ b/activitystreams-traits/src/lib.rs @@ -0,0 +1,38 @@ +/* + * This file is part of ActivityStreams Traits. + * + * Copyright © 2018 Riley Trautman + * + * ActivityStreams Traits 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 Traits 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 Traits. If not, see . + */ + +#[macro_use] +extern crate failure; +extern crate serde; +extern crate serde_json; + +mod activity; +mod actor; +mod collection; +mod error; +mod link; +mod object; +pub mod properties; + +pub use self::activity::*; +pub use self::actor::*; +pub use self::collection::*; +pub use self::error::*; +pub use self::link::*; +pub use self::object::*; diff --git a/activitystreams-traits/src/link.rs b/activitystreams-traits/src/link.rs new file mode 100644 index 0000000..66a1446 --- /dev/null +++ b/activitystreams-traits/src/link.rs @@ -0,0 +1,23 @@ +/* + * This file is part of ActivityStreams Traits. + * + * Copyright © 2018 Riley Trautman + * + * ActivityStreams Traits 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 Traits 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 Traits. If not, see . + */ + +use serde::{de::DeserializeOwned, ser::Serialize}; + +/// The Link is the secondary base type for the Activity Streams vocabulary. +pub trait Link: DeserializeOwned + Serialize {} diff --git a/activitystreams-traits/src/object.rs b/activitystreams-traits/src/object.rs new file mode 100644 index 0000000..d6eb5ef --- /dev/null +++ b/activitystreams-traits/src/object.rs @@ -0,0 +1,23 @@ +/* + * This file is part of ActivityStreams Traits. + * + * Copyright © 2018 Riley Trautman + * + * ActivityStreams Traits 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 Traits 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 Traits. If not, see . + */ + +use serde::{de::DeserializeOwned, ser::Serialize}; + +/// The Object is the primary base type for the Activity Streams vocabulary. +pub trait Object: DeserializeOwned + Serialize {} diff --git a/activitystreams-traits/src/properties.rs b/activitystreams-traits/src/properties.rs new file mode 100644 index 0000000..2cc1c64 --- /dev/null +++ b/activitystreams-traits/src/properties.rs @@ -0,0 +1,90 @@ +/* + * This file is part of ActivityStreams Traits. + * + * Copyright © 2018 Riley Trautman + * + * ActivityStreams Traits 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 Traits 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 Traits. If not, see . + */ + +//! A module containing helpers for tranlsating common JSON representations to and from concrete +//! types + +use serde::{de::DeserializeOwned, ser::Serialize}; +use serde_json; + +use error::{Error, Result}; + +/// Deserialize a `Value` into concrete type I +pub fn from_value(item: &serde_json::Value) -> Result +where + I: DeserializeOwned, +{ + serde_json::from_value(item.clone()).map_err(|_| Error::Deserialize) +} + +/// Serialize concrete type I into a `Value` +pub fn to_value(item: I) -> Result +where + I: Serialize, +{ + serde_json::to_value(item).map_err(|_| Error::Serialize) +} + +/// Deserialize an `Option` into concrete type I +pub fn from_item(item: &Option) -> Result +where + I: DeserializeOwned, +{ + if let &Some(ref item) = item { + from_value(item) + } else { + Err(Error::NotFound) + } +} + +/// Serialize concrete type I into an `Option` +pub fn to_item(item: I) -> Result> +where + I: Serialize, +{ + to_value(item).map(Some) +} + +/// Deserialize a `Vec` into a `Vec` +pub fn from_vec(v: &Vec) -> Result> +where + I: DeserializeOwned, +{ + v.iter().fold(Ok(Vec::new()), |acc, item| match acc { + Ok(mut acc) => from_value(item).map(|item| { + acc.push(item); + acc + }), + e => e, + }) +} + +/// Serialize a `Vec` into a `Vec` +pub fn to_vec(v: Vec) -> Result> +where + I: Serialize, +{ + v.into_iter().fold(Ok(Vec::new()), |acc, item| match acc { + Ok(mut acc) => to_value(item).map(|item| { + acc.push(item); + acc + }), + e => e, + }) +} diff --git a/activitystreams-types/Cargo.toml b/activitystreams-types/Cargo.toml new file mode 100644 index 0000000..bb205c2 --- /dev/null +++ b/activitystreams-types/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "activitystreams-types" +description = "Base types from the Activity Streams spec" +version = "0.1.0" +license = "GPL-3.0" +authors = ["asonix "] +repository = "https://github.com/asonix/activitystreams" +keywords = ["activitystreams", "activitypub"] + +[dependencies] +activitystreams-derive = { version = "0.1", path = "../activitystreams-derive" } +activitystreams-traits = { version = "0.1", path = "../activitystreams-traits" } +chrono = { version = "0.4", features = ["serde"] } +mime = "0.3" +serde = "1.0" +serde_derive = "1.0" +serde_json = "1.0" diff --git a/src/activity/accept.rs b/activitystreams-types/src/activity/accept.rs similarity index 69% rename from src/activity/accept.rs rename to activitystreams-types/src/activity/accept.rs index ad4f288..04b74d0 100644 --- a/src/activity/accept.rs +++ b/activitystreams-types/src/activity/accept.rs @@ -1,28 +1,27 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ +use activitystreams_traits::{Activity, Link, Object}; use serde_json; -use super::{kind::AcceptType, properties::ActivityProperties, Activity}; - -use link::Link; -use object::{properties::ObjectProperties, Object}; +use super::{kind::AcceptType, properties::ActivityProperties}; +use object::properties::ObjectProperties; #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[serde(rename_all = "camelCase")] diff --git a/src/activity/add.rs b/activitystreams-types/src/activity/add.rs similarity index 69% rename from src/activity/add.rs rename to activitystreams-types/src/activity/add.rs index 2e9a479..435db29 100644 --- a/src/activity/add.rs +++ b/activitystreams-types/src/activity/add.rs @@ -1,28 +1,27 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ +use activitystreams_traits::{Activity, Link, Object}; use serde_json; -use super::{kind::AddType, properties::ActivityProperties, Activity}; - -use link::Link; -use object::{properties::ObjectProperties, Object}; +use super::{kind::AddType, properties::ActivityProperties}; +use object::properties::ObjectProperties; #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[serde(rename_all = "camelCase")] diff --git a/src/activity/amove.rs b/activitystreams-types/src/activity/amove.rs similarity index 74% rename from src/activity/amove.rs rename to activitystreams-types/src/activity/amove.rs index 043a22c..a6e685a 100644 --- a/src/activity/amove.rs +++ b/activitystreams-types/src/activity/amove.rs @@ -1,28 +1,27 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ +use activitystreams_traits::{Activity, Link, Object}; use serde_json; -use super::{kind::MoveType, properties::ActivityProperties, Activity}; - -use link::Link; -use object::{properties::ObjectProperties, Object}; +use super::{kind::MoveType, properties::ActivityProperties}; +use object::properties::ObjectProperties; #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[serde(rename_all = "camelCase")] diff --git a/src/activity/announce.rs b/activitystreams-types/src/activity/announce.rs similarity index 72% rename from src/activity/announce.rs rename to activitystreams-types/src/activity/announce.rs index 8558f79..e8d34e9 100644 --- a/src/activity/announce.rs +++ b/activitystreams-types/src/activity/announce.rs @@ -1,28 +1,27 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ +use activitystreams_traits::{Activity, Link, Object}; use serde_json; -use super::{kind::AnnounceType, properties::ActivityProperties, Activity}; - -use link::Link; -use object::{properties::ObjectProperties, Object}; +use super::{kind::AnnounceType, properties::ActivityProperties}; +use object::properties::ObjectProperties; #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[serde(rename_all = "camelCase")] diff --git a/src/activity/arrive.rs b/activitystreams-types/src/activity/arrive.rs similarity index 70% rename from src/activity/arrive.rs rename to activitystreams-types/src/activity/arrive.rs index 853a1ab..730b9fb 100644 --- a/src/activity/arrive.rs +++ b/activitystreams-types/src/activity/arrive.rs @@ -1,28 +1,27 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ +use activitystreams_traits::{Activity, IntransitiveActivity, Link, Object}; use serde_json; -use super::{kind::ArriveType, properties::ActivityProperties, Activity, IntransitiveActivity}; - -use link::Link; -use object::{properties::ObjectProperties, Object}; +use super::{kind::ArriveType, properties::ActivityProperties}; +use object::properties::ObjectProperties; #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[serde(rename_all = "camelCase")] diff --git a/src/activity/block.rs b/activitystreams-types/src/activity/block.rs similarity index 69% rename from src/activity/block.rs rename to activitystreams-types/src/activity/block.rs index c341324..77edbd4 100644 --- a/src/activity/block.rs +++ b/activitystreams-types/src/activity/block.rs @@ -1,28 +1,27 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ +use activitystreams_traits::{Activity, Link, Object}; use serde_json; -use super::{kind::BlockType, properties::ActivityProperties, Activity}; - -use link::Link; -use object::{properties::ObjectProperties, Object}; +use super::{kind::BlockType, properties::ActivityProperties}; +use object::properties::ObjectProperties; #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[serde(rename_all = "camelCase")] diff --git a/src/activity/create.rs b/activitystreams-types/src/activity/create.rs similarity index 69% rename from src/activity/create.rs rename to activitystreams-types/src/activity/create.rs index 955ed62..d831852 100644 --- a/src/activity/create.rs +++ b/activitystreams-types/src/activity/create.rs @@ -1,28 +1,27 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ +use activitystreams_traits::{Activity, Link, Object}; use serde_json; -use super::{kind::CreateType, properties::ActivityProperties, Activity}; - -use link::Link; -use object::{properties::ObjectProperties, Object}; +use super::{kind::CreateType, properties::ActivityProperties}; +use object::properties::ObjectProperties; #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[serde(rename_all = "camelCase")] diff --git a/src/activity/delete.rs b/activitystreams-types/src/activity/delete.rs similarity index 72% rename from src/activity/delete.rs rename to activitystreams-types/src/activity/delete.rs index 4980f36..09e57d6 100644 --- a/src/activity/delete.rs +++ b/activitystreams-types/src/activity/delete.rs @@ -1,28 +1,27 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ +use activitystreams_traits::{Activity, Link, Object}; use serde_json; -use super::{kind::DeleteType, properties::ActivityProperties, Activity}; - -use link::Link; -use object::{properties::ObjectProperties, Object}; +use super::{kind::DeleteType, properties::ActivityProperties}; +use object::properties::ObjectProperties; #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[serde(rename_all = "camelCase")] diff --git a/src/activity/dislike.rs b/activitystreams-types/src/activity/dislike.rs similarity index 69% rename from src/activity/dislike.rs rename to activitystreams-types/src/activity/dislike.rs index e217912..8a35128 100644 --- a/src/activity/dislike.rs +++ b/activitystreams-types/src/activity/dislike.rs @@ -1,28 +1,27 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ +use activitystreams_traits::{Activity, Link, Object}; use serde_json; -use super::{kind::DislikeType, properties::ActivityProperties, Activity}; - -use link::Link; -use object::{properties::ObjectProperties, Object}; +use super::{kind::DislikeType, properties::ActivityProperties}; +use object::properties::ObjectProperties; #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[serde(rename_all = "camelCase")] diff --git a/src/activity/flag.rs b/activitystreams-types/src/activity/flag.rs similarity index 69% rename from src/activity/flag.rs rename to activitystreams-types/src/activity/flag.rs index c021557..8c3d69c 100644 --- a/src/activity/flag.rs +++ b/activitystreams-types/src/activity/flag.rs @@ -1,28 +1,27 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ +use activitystreams_traits::{Activity, Link, Object}; use serde_json; -use super::{kind::FlagType, properties::ActivityProperties, Activity}; - -use link::Link; -use object::{properties::ObjectProperties, Object}; +use super::{kind::FlagType, properties::ActivityProperties}; +use object::properties::ObjectProperties; #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[serde(rename_all = "camelCase")] diff --git a/src/activity/follow.rs b/activitystreams-types/src/activity/follow.rs similarity index 69% rename from src/activity/follow.rs rename to activitystreams-types/src/activity/follow.rs index 9beffbb..640032f 100644 --- a/src/activity/follow.rs +++ b/activitystreams-types/src/activity/follow.rs @@ -1,28 +1,27 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ +use activitystreams_traits::{Activity, Link, Object}; use serde_json; -use super::{kind::FollowType, properties::ActivityProperties, Activity}; - -use link::Link; -use object::{properties::ObjectProperties, Object}; +use super::{kind::FollowType, properties::ActivityProperties}; +use object::properties::ObjectProperties; #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[serde(rename_all = "camelCase")] diff --git a/src/activity/ignore.rs b/activitystreams-types/src/activity/ignore.rs similarity index 69% rename from src/activity/ignore.rs rename to activitystreams-types/src/activity/ignore.rs index 9f65caf..ee93e53 100644 --- a/src/activity/ignore.rs +++ b/activitystreams-types/src/activity/ignore.rs @@ -1,28 +1,27 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ +use activitystreams_traits::{Activity, Link, Object}; use serde_json; -use super::{kind::IgnoreType, properties::ActivityProperties, Activity}; - -use link::Link; -use object::{properties::ObjectProperties, Object}; +use super::{kind::IgnoreType, properties::ActivityProperties}; +use object::properties::ObjectProperties; #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[serde(rename_all = "camelCase")] diff --git a/src/activity/invite.rs b/activitystreams-types/src/activity/invite.rs similarity index 70% rename from src/activity/invite.rs rename to activitystreams-types/src/activity/invite.rs index ede2b8b..f1ea394 100644 --- a/src/activity/invite.rs +++ b/activitystreams-types/src/activity/invite.rs @@ -1,28 +1,27 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ +use activitystreams_traits::{Activity, Link, Object}; use serde_json; -use super::{kind::InviteType, properties::ActivityProperties, Activity}; - -use link::Link; -use object::{properties::ObjectProperties, Object}; +use super::{kind::InviteType, properties::ActivityProperties}; +use object::properties::ObjectProperties; #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[serde(rename_all = "camelCase")] diff --git a/src/activity/join.rs b/activitystreams-types/src/activity/join.rs similarity index 69% rename from src/activity/join.rs rename to activitystreams-types/src/activity/join.rs index 53618cd..126d56a 100644 --- a/src/activity/join.rs +++ b/activitystreams-types/src/activity/join.rs @@ -1,28 +1,27 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ +use activitystreams_traits::{Activity, Link, Object}; use serde_json; -use super::{kind::JoinType, properties::ActivityProperties, Activity}; - -use link::Link; -use object::{properties::ObjectProperties, Object}; +use super::{kind::JoinType, properties::ActivityProperties}; +use object::properties::ObjectProperties; #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[serde(rename_all = "camelCase")] diff --git a/src/activity/kind.rs b/activitystreams-types/src/activity/kind.rs similarity index 92% rename from src/activity/kind.rs rename to activitystreams-types/src/activity/kind.rs index dd192f6..a9b9418 100644 --- a/src/activity/kind.rs +++ b/activitystreams-types/src/activity/kind.rs @@ -1,20 +1,20 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ use std::fmt; diff --git a/src/activity/leave.rs b/activitystreams-types/src/activity/leave.rs similarity index 69% rename from src/activity/leave.rs rename to activitystreams-types/src/activity/leave.rs index 3871788..9ef1e97 100644 --- a/src/activity/leave.rs +++ b/activitystreams-types/src/activity/leave.rs @@ -1,28 +1,27 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ +use activitystreams_traits::{Activity, Link, Object}; use serde_json; -use super::{kind::LeaveType, properties::ActivityProperties, Activity}; - -use link::Link; -use object::{properties::ObjectProperties, Object}; +use super::{kind::LeaveType, properties::ActivityProperties}; +use object::properties::ObjectProperties; #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[serde(rename_all = "camelCase")] diff --git a/src/activity/like.rs b/activitystreams-types/src/activity/like.rs similarity index 69% rename from src/activity/like.rs rename to activitystreams-types/src/activity/like.rs index 791e31a..03a95a0 100644 --- a/src/activity/like.rs +++ b/activitystreams-types/src/activity/like.rs @@ -1,28 +1,27 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ +use activitystreams_traits::{Activity, Link, Object}; use serde_json; -use super::{kind::LikeType, properties::ActivityProperties, Activity}; - -use link::Link; -use object::{properties::ObjectProperties, Object}; +use super::{kind::LikeType, properties::ActivityProperties}; +use object::properties::ObjectProperties; #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[serde(rename_all = "camelCase")] diff --git a/src/activity/listen.rs b/activitystreams-types/src/activity/listen.rs similarity index 69% rename from src/activity/listen.rs rename to activitystreams-types/src/activity/listen.rs index e00b281..fe8647f 100644 --- a/src/activity/listen.rs +++ b/activitystreams-types/src/activity/listen.rs @@ -1,28 +1,27 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ +use activitystreams_traits::{Activity, Link, Object}; use serde_json; -use super::{kind::ListenType, properties::ActivityProperties, Activity}; - -use link::Link; -use object::{properties::ObjectProperties, Object}; +use super::{kind::ListenType, properties::ActivityProperties}; +use object::properties::ObjectProperties; #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[serde(rename_all = "camelCase")] diff --git a/src/activity/mod.rs b/activitystreams-types/src/activity/mod.rs similarity index 81% rename from src/activity/mod.rs rename to activitystreams-types/src/activity/mod.rs index babe197..212d4b6 100644 --- a/src/activity/mod.rs +++ b/activitystreams-types/src/activity/mod.rs @@ -1,24 +1,22 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ -use object::Object; - mod accept; mod add; mod amove; @@ -79,6 +77,3 @@ pub use self::travel::*; pub use self::undo::*; pub use self::update::*; pub use self::view::*; - -pub trait Activity: Object {} -pub trait IntransitiveActivity: Activity {} diff --git a/src/activity/offer.rs b/activitystreams-types/src/activity/offer.rs similarity index 71% rename from src/activity/offer.rs rename to activitystreams-types/src/activity/offer.rs index 5ee9baa..78ddd60 100644 --- a/src/activity/offer.rs +++ b/activitystreams-types/src/activity/offer.rs @@ -1,28 +1,27 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ +use activitystreams_traits::{Activity, Link, Object}; use serde_json; -use super::{kind::OfferType, properties::ActivityProperties, Activity}; - -use link::Link; -use object::{properties::ObjectProperties, Object}; +use super::{kind::OfferType, properties::ActivityProperties}; +use object::properties::ObjectProperties; #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[serde(rename_all = "camelCase")] diff --git a/src/activity/properties.rs b/activitystreams-types/src/activity/properties.rs similarity index 73% rename from src/activity/properties.rs rename to activitystreams-types/src/activity/properties.rs index d98d90f..41fc3a7 100644 --- a/src/activity/properties.rs +++ b/activitystreams-types/src/activity/properties.rs @@ -1,27 +1,25 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ +use activitystreams_traits::{Link, Object}; use serde_json; -use link::Link; -use object::Object; - #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[serde(rename_all = "camelCase")] pub struct ActivityProperties { diff --git a/src/activity/question.rs b/activitystreams-types/src/activity/question.rs similarity index 72% rename from src/activity/question.rs rename to activitystreams-types/src/activity/question.rs index 6ad1e8e..ddd42e3 100644 --- a/src/activity/question.rs +++ b/activitystreams-types/src/activity/question.rs @@ -1,28 +1,27 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ +use activitystreams_traits::{Activity, IntransitiveActivity, Link, Object}; use serde_json; -use super::{kind::QuestionType, properties::ActivityProperties, Activity, IntransitiveActivity}; - -use link::Link; -use object::{properties::ObjectProperties, Object}; +use super::{kind::QuestionType, properties::ActivityProperties}; +use object::properties::ObjectProperties; #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[serde(rename_all = "camelCase")] diff --git a/src/activity/read.rs b/activitystreams-types/src/activity/read.rs similarity index 69% rename from src/activity/read.rs rename to activitystreams-types/src/activity/read.rs index fc83bf5..3d81e0b 100644 --- a/src/activity/read.rs +++ b/activitystreams-types/src/activity/read.rs @@ -1,28 +1,27 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ +use activitystreams_traits::{Activity, Link, Object}; use serde_json; -use super::{kind::ReadType, properties::ActivityProperties, Activity}; - -use link::Link; -use object::{properties::ObjectProperties, Object}; +use super::{kind::ReadType, properties::ActivityProperties}; +use object::properties::ObjectProperties; #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[serde(rename_all = "camelCase")] diff --git a/src/activity/reject.rs b/activitystreams-types/src/activity/reject.rs similarity index 69% rename from src/activity/reject.rs rename to activitystreams-types/src/activity/reject.rs index 191033b..c0772b4 100644 --- a/src/activity/reject.rs +++ b/activitystreams-types/src/activity/reject.rs @@ -1,28 +1,27 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ +use activitystreams_traits::{Activity, Link, Object}; use serde_json; -use super::{kind::RejectType, properties::ActivityProperties, Activity}; - -use link::Link; -use object::{properties::ObjectProperties, Object}; +use super::{kind::RejectType, properties::ActivityProperties}; +use object::properties::ObjectProperties; #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[serde(rename_all = "camelCase")] diff --git a/src/activity/remove.rs b/activitystreams-types/src/activity/remove.rs similarity index 74% rename from src/activity/remove.rs rename to activitystreams-types/src/activity/remove.rs index ac2bcdb..8c61d71 100644 --- a/src/activity/remove.rs +++ b/activitystreams-types/src/activity/remove.rs @@ -1,28 +1,27 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ +use activitystreams_traits::{Activity, Link, Object}; use serde_json; -use super::{kind::RemoveType, properties::ActivityProperties, Activity}; - -use link::Link; -use object::{properties::ObjectProperties, Object}; +use super::{kind::RemoveType, properties::ActivityProperties}; +use object::properties::ObjectProperties; #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[serde(rename_all = "camelCase")] diff --git a/src/activity/tentative_accept.rs b/activitystreams-types/src/activity/tentative_accept.rs similarity index 74% rename from src/activity/tentative_accept.rs rename to activitystreams-types/src/activity/tentative_accept.rs index 679893f..a6f6db7 100644 --- a/src/activity/tentative_accept.rs +++ b/activitystreams-types/src/activity/tentative_accept.rs @@ -1,28 +1,27 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ +use activitystreams_traits::{Activity, Link, Object}; use serde_json; -use super::{kind::TentativeAcceptType, properties::ActivityProperties, Activity}; - -use link::Link; -use object::{properties::ObjectProperties, Object}; +use super::{kind::TentativeAcceptType, properties::ActivityProperties}; +use object::properties::ObjectProperties; #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[serde(rename_all = "camelCase")] diff --git a/src/activity/tentative_reject.rs b/activitystreams-types/src/activity/tentative_reject.rs similarity index 74% rename from src/activity/tentative_reject.rs rename to activitystreams-types/src/activity/tentative_reject.rs index ca48a61..9948131 100644 --- a/src/activity/tentative_reject.rs +++ b/activitystreams-types/src/activity/tentative_reject.rs @@ -1,28 +1,27 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ +use activitystreams_traits::{Activity, Link, Object}; use serde_json; -use super::{kind::TentativeRejectType, properties::ActivityProperties, Activity}; - -use link::Link; -use object::{properties::ObjectProperties, Object}; +use super::{kind::TentativeRejectType, properties::ActivityProperties}; +use object::properties::ObjectProperties; #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[serde(rename_all = "camelCase")] diff --git a/src/activity/travel.rs b/activitystreams-types/src/activity/travel.rs similarity index 72% rename from src/activity/travel.rs rename to activitystreams-types/src/activity/travel.rs index 62f7761..b3fa1d2 100644 --- a/src/activity/travel.rs +++ b/activitystreams-types/src/activity/travel.rs @@ -1,28 +1,27 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ +use activitystreams_traits::{Activity, IntransitiveActivity, Link, Object}; use serde_json; -use super::{kind::TravelType, properties::ActivityProperties, Activity, IntransitiveActivity}; - -use link::Link; -use object::{properties::ObjectProperties, Object}; +use super::{kind::TravelType, properties::ActivityProperties}; +use object::properties::ObjectProperties; #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[serde(rename_all = "camelCase")] diff --git a/src/activity/undo.rs b/activitystreams-types/src/activity/undo.rs similarity index 69% rename from src/activity/undo.rs rename to activitystreams-types/src/activity/undo.rs index 977733e..6375f9b 100644 --- a/src/activity/undo.rs +++ b/activitystreams-types/src/activity/undo.rs @@ -1,28 +1,27 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ +use activitystreams_traits::{Activity, Link, Object}; use serde_json; -use super::{kind::UndoType, properties::ActivityProperties, Activity}; - -use link::Link; -use object::{properties::ObjectProperties, Object}; +use super::{kind::UndoType, properties::ActivityProperties}; +use object::properties::ObjectProperties; #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[serde(rename_all = "camelCase")] diff --git a/src/activity/update.rs b/activitystreams-types/src/activity/update.rs similarity index 69% rename from src/activity/update.rs rename to activitystreams-types/src/activity/update.rs index 792aeb1..9f85ba6 100644 --- a/src/activity/update.rs +++ b/activitystreams-types/src/activity/update.rs @@ -1,28 +1,27 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ +use activitystreams_traits::{Activity, Link, Object}; use serde_json; -use super::{kind::UpdateType, properties::ActivityProperties, Activity}; - -use link::Link; -use object::{properties::ObjectProperties, Object}; +use super::{kind::UpdateType, properties::ActivityProperties}; +use object::properties::ObjectProperties; #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[serde(rename_all = "camelCase")] diff --git a/src/activity/view.rs b/activitystreams-types/src/activity/view.rs similarity index 69% rename from src/activity/view.rs rename to activitystreams-types/src/activity/view.rs index fddf776..9f3092b 100644 --- a/src/activity/view.rs +++ b/activitystreams-types/src/activity/view.rs @@ -1,28 +1,27 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ +use activitystreams_traits::{Activity, Link, Object}; use serde_json; -use super::{kind::ViewType, properties::ActivityProperties, Activity}; - -use link::Link; -use object::{properties::ObjectProperties, Object}; +use super::{kind::ViewType, properties::ActivityProperties}; +use object::properties::ObjectProperties; #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[serde(rename_all = "camelCase")] diff --git a/src/actor/kind.rs b/activitystreams-types/src/actor/kind.rs similarity index 76% rename from src/actor/kind.rs rename to activitystreams-types/src/actor/kind.rs index bfa59ce..c2c2717 100644 --- a/src/actor/kind.rs +++ b/activitystreams-types/src/actor/kind.rs @@ -1,22 +1,24 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ +//! Namespace for Unit Structs that serialize to strings + use std::fmt; use serde::{ diff --git a/src/actor/mod.rs b/activitystreams-types/src/actor/mod.rs similarity index 64% rename from src/actor/mod.rs rename to activitystreams-types/src/actor/mod.rs index 10a7ca2..d617809 100644 --- a/src/actor/mod.rs +++ b/activitystreams-types/src/actor/mod.rs @@ -1,85 +1,102 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ -use object::{properties::ObjectProperties, Object}; +//! Namespace for Actor types + +use activitystreams_traits::{Actor, Object}; + +use object::properties::ObjectProperties; mod kind; pub use self::kind::*; -pub trait Actor: Object {} - +/// Describes a software application. #[derive(Clone, Debug, Default, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Appliation { #[serde(rename = "type")] kind: ApplicationType, + /// Adds all valid object properties to this struct #[serde(flatten)] pub object_props: ObjectProperties, } impl Object for Appliation {} +impl Actor for Appliation {} +/// Represents a formal or informal collective of Actors. #[derive(Clone, Debug, Default, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Group { #[serde(rename = "type")] kind: GroupType, + /// Adds all valid object properties to this struct #[serde(flatten)] pub object_props: ObjectProperties, } impl Object for Group {} +impl Actor for Group {} +/// Represents an organization. #[derive(Clone, Debug, Default, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Organization { #[serde(rename = "type")] kind: OrganizationType, + /// Adds all valid object properties to this struct #[serde(flatten)] pub object_props: ObjectProperties, } impl Object for Organization {} +impl Actor for Organization {} +/// Represents an individual person. #[derive(Clone, Debug, Default, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Person { #[serde(rename = "type")] kind: PersonType, + /// Adds all valid object properties to this struct #[serde(flatten)] pub object_props: ObjectProperties, } impl Object for Person {} +impl Actor for Person {} +/// Represents a service of any kind. #[derive(Clone, Debug, Default, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Service { #[serde(rename = "type")] kind: ServiceType, + /// Adds all valid object properties to this struct #[serde(flatten)] pub object_props: ObjectProperties, } impl Object for Service {} +impl Actor for Service {} diff --git a/src/collection/kind.rs b/activitystreams-types/src/collection/kind.rs similarity index 75% rename from src/collection/kind.rs rename to activitystreams-types/src/collection/kind.rs index 59e7b17..5d5db8a 100644 --- a/src/collection/kind.rs +++ b/activitystreams-types/src/collection/kind.rs @@ -1,22 +1,24 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ +//! Namespace for Unit Structs that serialize to strings + use std::fmt; use serde::{ diff --git a/src/collection/mod.rs b/activitystreams-types/src/collection/mod.rs similarity index 86% rename from src/collection/mod.rs rename to activitystreams-types/src/collection/mod.rs index d9287cd..808c0a8 100644 --- a/src/collection/mod.rs +++ b/activitystreams-types/src/collection/mod.rs @@ -1,35 +1,33 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ -use object::{properties::ObjectProperties, Object}; +//! Namespace for Collection types + +use activitystreams_traits::{Collection, CollectionPage, Object}; + +use object::properties::ObjectProperties; pub mod kind; pub mod properties; use self::kind::*; use self::properties::*; -/// A Collection is a subtype of `Object` that represents ordered or unordered sets of `Object` or -/// `Link` instances. -pub trait Collection: Object {} - -pub trait CollectionPage: Object {} - #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[serde(rename_all = "camelCase")] pub struct UnorderedCollection { @@ -90,6 +88,7 @@ pub struct UnorderedCollectionPage { impl Object for UnorderedCollectionPage {} impl Collection for UnorderedCollectionPage {} +impl CollectionPage for UnorderedCollectionPage {} /// Used to represent ordered subsets of items from an `OrderedCollection`. #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] @@ -117,3 +116,4 @@ pub struct OrderedCollectionPage { impl Object for OrderedCollectionPage {} impl Collection for OrderedCollectionPage {} +impl CollectionPage for OrderedCollectionPage {} diff --git a/src/collection/properties.rs b/activitystreams-types/src/collection/properties.rs similarity index 78% rename from src/collection/properties.rs rename to activitystreams-types/src/collection/properties.rs index cf477dc..65de1d4 100644 --- a/src/collection/properties.rs +++ b/activitystreams-types/src/collection/properties.rs @@ -1,20 +1,20 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ //! Namespace for properties of standard object types @@ -56,14 +56,9 @@ //! # fn main() {} //! ``` +use activitystreams_traits::{Collection, CollectionPage, Link, Object}; use serde_json; -use super::{ - OrderedCollection, OrderedCollectionPage, UnorderedCollection, UnorderedCollectionPage, -}; -use link::Link; -use object::Object; - /// `Collection` objects are a specialization of the base `Object` that serve as a container for /// other `Objects` or `Links`. /// @@ -96,32 +91,26 @@ pub struct CollectionProperties { /// In a paged `Collection`, indicates the page that contains the most recently updated member /// items. /// - /// - Range: `CollectionPage` | `OrderedCollectionPage` | `Link` + /// - Range: `CollectionPage` | `Link` /// - Functional: true #[serde(skip_serializing_if = "Option::is_none")] - #[activitystreams( - concrete(UnorderedCollectionPage, OrderedCollectionPage), ab(Link), functional - )] + #[activitystreams(ab(Link, CollectionPage), functional)] pub current: Option, /// In a paged `Collection`, indicates the furthest preceeding page of items in the collection. /// - /// - Range: `CollectionPage` | `OrderedCollectionPage` | `Link` + /// - Range: `CollectionPage` | `Link` /// - Functional: true #[serde(skip_serializing_if = "Option::is_none")] - #[activitystreams( - concrete(UnorderedCollectionPage, OrderedCollectionPage), ab(Link), functional - )] + #[activitystreams(ab(Link, CollectionPage), functional)] pub first: Option, /// In a paged `Collection`, indicates the furthest proceeding page of the collection. /// - /// - Range: `CollectionPage` | `OrderedCollectionPage` | `Link` + /// - Range: `CollectionPage` | `Link` /// - Functional: true #[serde(skip_serializing_if = "Option::is_none")] - #[activitystreams( - concrete(UnorderedCollectionPage, OrderedCollectionPage), ab(Link), functional - )] + #[activitystreams(ab(Link, CollectionPage), functional)] pub last: Option, } @@ -132,26 +121,26 @@ pub struct CollectionProperties { pub struct CollectionPageProperties { /// Identifies the `Collection` to which a `CollectionPage` objects items belong. /// - /// Range: `Collection` | `OrderedCollection` | `Link` + /// Range: `Collection` | `Link` /// Functional: true #[serde(skip_serializing_if = "Option::is_none")] - #[activitystreams(concrete(UnorderedCollection, OrderedCollection), ab(Link), functional)] + #[activitystreams(ab(Link, Collection), functional)] pub part_of: Option, /// In a paged `Collection`, indicates the next page of items. /// - /// - Range: `CollectionPage` | `OrderedCollectionPage` | `Link` + /// - Range: `CollectionPage` | `Link` /// - Functional: true #[serde(skip_serializing_if = "Option::is_none")] - #[activitystreams(concrete(UnorderedCollectionPage), ab(Link), functional)] + #[activitystreams(ab(Link, CollectionPage), functional)] pub next: Option, /// In a paged `Collection`, identifies the previous page of items. /// - /// - Range: `CollectionPage` | `OrderedCollectionPage` | `Link` + /// - Range: `CollectionPage` | `Link` /// - Functional: true #[serde(skip_serializing_if = "Option::is_none")] - #[activitystreams(concrete(UnorderedCollectionPage), ab(Link), functional)] + #[activitystreams(ab(Link, CollectionPage), functional)] pub prev: Option, } diff --git a/activitystreams-types/src/custom_props.rs b/activitystreams-types/src/custom_props.rs new file mode 100644 index 0000000..cec344a --- /dev/null +++ b/activitystreams-types/src/custom_props.rs @@ -0,0 +1,150 @@ +/* + * This file is part of ActivityStreams Types. + * + * Copyright © 2018 Riley Trautman + * + * ActivityStreams Types 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 Types 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 Types. If not, see . + */ + +//! A collection of simple types for extending the ActivityStreams Types base types + +use serde::{de::DeserializeOwned, ser::Serialize}; + +use activitystreams_traits::{ + Activity, Actor, Collection, CollectionPage, IntransitiveActivity, Link, Object, +}; + +/// A custom type extending Link +/// +/// CustomLink allows for providing a pre-defined Link type, and a set of extending properties, and +/// treating those two items as a single Link type. +/// +/// ## Example +/// ```rust +/// use activitystreams::{ +/// custom_props::CustomLink, +/// link::Mention, +/// }; +/// +/// struct MyProps { +/// some_prop: String, +/// } +/// +/// fn main() { +/// let mention = Mention::default(); +/// let extended_mention = CustomLink::new(mention, MyProps { some_prop: "hey".to_owned() }); +/// } +/// ``` +#[derive(Clone, Debug, Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct CustomLink { + #[serde(flatten)] + pub link: L, + + #[serde(flatten)] + pub custom_props: C, +} + +impl CustomLink { + pub fn new(link: L, custom_props: C) -> Self { + CustomLink { link, custom_props } + } +} + +impl Link for CustomLink +where + C: DeserializeOwned + Serialize, + L: Link, +{ +} + +/// A custom type extending Object +/// +/// CustomObject allows for providing a pre-defined Link type, and a set of extending properties, +/// and treating those two items as a single Object type. +/// +/// This type can also be used to extend any type deriving from Object, such as Actor, Activity, or +/// Collection. +/// +/// ## Example +/// ```rust +/// use activitystreams::{ +/// custom_props::CustomObject, +/// object::Video, +/// }; +/// +/// struct MyProps { +/// some_prop: String, +/// } +/// +/// fn main() { +/// let video = Video::default(); +/// let extended_video = CustomObject::new(video, MyProps { some_prop: "hey".to_owned() }); +/// } +/// ``` +#[derive(Clone, Debug, Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct CustomObject { + #[serde(flatten)] + pub object: O, + + #[serde(flatten)] + pub custom_props: C, +} + +impl CustomObject { + pub fn new(object: O, custom_props: C) -> Self { + CustomObject { + object, + custom_props, + } + } +} + +impl Object for CustomObject +where + C: DeserializeOwned + Serialize, + O: Object, +{ +} +impl Actor for CustomObject +where + C: DeserializeOwned + Serialize, + O: Actor, +{ +} +impl Collection for CustomObject +where + C: DeserializeOwned + Serialize, + O: Collection, +{ +} +impl CollectionPage for CustomObject +where + C: DeserializeOwned + Serialize, + O: CollectionPage, +{ +} +impl Activity for CustomObject +where + C: DeserializeOwned + Serialize, + O: Activity, +{ +} +impl IntransitiveActivity for CustomObject +where + C: DeserializeOwned + Serialize, + O: IntransitiveActivity, +{ +} diff --git a/activitystreams-types/src/lib.rs b/activitystreams-types/src/lib.rs new file mode 100644 index 0000000..c655ae8 --- /dev/null +++ b/activitystreams-types/src/lib.rs @@ -0,0 +1,44 @@ +/* + * This file is part of ActivityStreams Types. + * + * Copyright © 2018 Riley Trautman + * + * ActivityStreams Types 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 Types 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 Types. If not, see . + */ + +#[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; +#[macro_use] +extern crate serde_json; + +pub fn context() -> serde_json::Value { + json!({ + "one": "two", + }) +} + +pub mod activity; +pub mod actor; +pub mod collection; +mod custom_props; +pub mod link; +pub mod object; + +pub use self::custom_props::{CustomLink, CustomObject}; diff --git a/src/link/kind.rs b/activitystreams-types/src/link/kind.rs similarity index 73% rename from src/link/kind.rs rename to activitystreams-types/src/link/kind.rs index f909fd1..fdb9662 100644 --- a/src/link/kind.rs +++ b/activitystreams-types/src/link/kind.rs @@ -1,20 +1,20 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ //! Namespace for Unit Structs that serialize to strings diff --git a/src/link/mod.rs b/activitystreams-types/src/link/mod.rs similarity index 67% rename from src/link/mod.rs rename to activitystreams-types/src/link/mod.rs index ee78581..8d68ed2 100644 --- a/src/link/mod.rs +++ b/activitystreams-types/src/link/mod.rs @@ -1,32 +1,31 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ -use serde::{de::DeserializeOwned, ser::Serialize}; +//! Namespace for Link types + +use activitystreams_traits::Link; pub mod kind; pub mod properties; use self::kind::*; use self::properties::*; -/// The Link is the secondary base type for the Activity Streams vocabulary. -pub trait Link: DeserializeOwned + Serialize {} - /// A specialized Link that represents an @mention. #[derive(Clone, Debug, Default, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] diff --git a/src/link/properties.rs b/activitystreams-types/src/link/properties.rs similarity index 94% rename from src/link/properties.rs rename to activitystreams-types/src/link/properties.rs index 88d10c6..a7102f4 100644 --- a/src/link/properties.rs +++ b/activitystreams-types/src/link/properties.rs @@ -1,20 +1,20 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ //! Namespace for properties of standard link types @@ -47,13 +47,10 @@ //! # fn main() {} //! ``` +use activitystreams_traits::{Error, Link, Object, Result}; use mime; use serde_json; -use error::{Error, Result}; -use link::Link; -use object::Object; - /// Define all the properties of the Object base type as described by the Activity Streams /// vocabulary. /// diff --git a/src/object/kind.rs b/activitystreams-types/src/object/kind.rs similarity index 89% rename from src/object/kind.rs rename to activitystreams-types/src/object/kind.rs index 99d5d88..3feb730 100644 --- a/src/object/kind.rs +++ b/activitystreams-types/src/object/kind.rs @@ -1,20 +1,20 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ //! Namespace for Unit Structs that serialize to strings diff --git a/src/object/mod.rs b/activitystreams-types/src/object/mod.rs similarity index 94% rename from src/object/mod.rs rename to activitystreams-types/src/object/mod.rs index 2ffbf9c..91e3e91 100644 --- a/src/object/mod.rs +++ b/activitystreams-types/src/object/mod.rs @@ -1,34 +1,31 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ //! Namespace for Object types -use serde::{de::DeserializeOwned, ser::Serialize}; +use activitystreams_traits::Object; pub mod kind; pub mod properties; use self::kind::*; use self::properties::*; -/// The Object is the primary base type for the Activity Streams vocabulary. -pub trait Object: DeserializeOwned + Serialize {} - /// Represents any kind of multi-paragraph written work. #[derive(Clone, Debug, Default, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] diff --git a/src/object/properties.rs b/activitystreams-types/src/object/properties.rs similarity index 97% rename from src/object/properties.rs rename to activitystreams-types/src/object/properties.rs index 1c5f395..711cec2 100644 --- a/src/object/properties.rs +++ b/activitystreams-types/src/object/properties.rs @@ -1,20 +1,20 @@ /* - * This file is part of ActivityStreams. + * This file is part of ActivityStreams Types. * * Copyright © 2018 Riley Trautman * - * ActivityStreams is free software: you can redistribute it and/or modify + * ActivityStreams Types 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, + * ActivityStreams Types 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 . + * along with ActivityStreams Types. If not, see . */ //! Namespace for properties of standard object types @@ -47,14 +47,12 @@ //! # fn main() {} //! ``` +use activitystreams_traits::{Collection, Error, Link, Object, Result}; use chrono::{offset::Utc, DateTime}; use mime; use serde_json; -use collection::Collection; -use error::{Error, Result}; -use link::Link; -use object::{Image, Object}; +use object::Image; /// Alias chrono::DateTime for use in derive macros pub type UtcTime = DateTime; diff --git a/src/activity.rs b/src/activity.rs new file mode 100644 index 0000000..628c3a7 --- /dev/null +++ b/src/activity.rs @@ -0,0 +1,21 @@ +/* + * This file is part of ActivityStreams. + * + * Copyright © 2018 Riley Trautman + * + * ActivityStreams is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * ActivityStreams is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with ActivityStreams. If not, see . + */ + +pub use activitystreams_traits::{Activity, IntransitiveActivity}; +pub use activitystreams_types::activity::*; diff --git a/src/actor.rs b/src/actor.rs new file mode 100644 index 0000000..4707800 --- /dev/null +++ b/src/actor.rs @@ -0,0 +1,21 @@ +/* + * This file is part of ActivityStreams. + * + * Copyright © 2018 Riley Trautman + * + * ActivityStreams is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * ActivityStreams is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with ActivityStreams. If not, see . + */ + +pub use activitystreams_traits::Actor; +pub use activitystreams_types::actor::*; diff --git a/src/collection.rs b/src/collection.rs new file mode 100644 index 0000000..923f0a0 --- /dev/null +++ b/src/collection.rs @@ -0,0 +1,21 @@ +/* + * This file is part of ActivityStreams. + * + * Copyright © 2018 Riley Trautman + * + * ActivityStreams is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * ActivityStreams is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with ActivityStreams. If not, see . + */ + +pub use activitystreams_traits::{Collection, CollectionPage}; +pub use activitystreams_types::collection::*; diff --git a/src/custom_props.rs b/src/custom_props.rs deleted file mode 100644 index f309220..0000000 --- a/src/custom_props.rs +++ /dev/null @@ -1,56 +0,0 @@ -/* - * This file is part of ActivityStreams. - * - * Copyright © 2018 Riley Trautman - * - * ActivityStreams is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * ActivityStreams is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ActivityStreams. If not, see . - */ - -use link::Link; -use object::Object; - -#[derive(Clone, Debug, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct CustomLink { - #[serde(flatten)] - pub link: L, - - #[serde(flatten)] - pub custom_props: C, -} - -impl CustomLink { - pub fn new(link: L, custom_props: C) -> Self { - CustomLink { link, custom_props } - } -} - -#[derive(Clone, Debug, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct CustomObject { - #[serde(flatten)] - pub object: O, - - #[serde(flatten)] - pub custom_props: C, -} - -impl CustomObject { - pub fn new(object: O, custom_props: C) -> Self { - CustomObject { - object, - custom_props, - } - } -} diff --git a/src/error.rs b/src/error.rs index 81998ed..5aa3b46 100644 --- a/src/error.rs +++ b/src/error.rs @@ -17,18 +17,4 @@ * along with ActivityStreams. If not, see . */ -use std::result; - -#[derive(Copy, Clone, Debug, Fail)] -pub enum Error { - #[fail(display = "Key not present")] - NotFound, - - #[fail(display = "Failed to deserialize data as requested type")] - Deserialize, - - #[fail(display = "Failed to serialize data")] - Serialize, -} - -pub type Result = result::Result; +pub use activitystreams_traits::{Error, Result}; diff --git a/src/lib.rs b/src/lib.rs index 2469258..5f0750d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,28 +17,12 @@ * along with ActivityStreams. If not, see . */ -#[macro_use] -extern crate activitystreams_derive; -extern crate chrono; -#[macro_use] -extern crate failure; -extern crate mime; -extern crate serde; -#[macro_use] -extern crate serde_derive; -#[macro_use] -extern crate serde_json; - -pub fn context() -> serde_json::Value { - json!({ - "one": "two", - }) -} +extern crate activitystreams_traits; +extern crate activitystreams_types; pub mod activity; pub mod actor; pub mod collection; -pub mod custom_props; pub mod error; pub mod link; pub mod object; @@ -47,7 +31,6 @@ pub mod properties; pub use self::activity::{Activity, IntransitiveActivity}; pub use self::actor::Actor; pub use self::collection::{Collection, CollectionPage}; -pub use self::custom_props::{CustomLink, CustomObject}; pub use self::error::Error; pub use self::link::Link; pub use self::object::Object; diff --git a/src/link.rs b/src/link.rs new file mode 100644 index 0000000..cf13628 --- /dev/null +++ b/src/link.rs @@ -0,0 +1,21 @@ +/* + * This file is part of ActivityStreams. + * + * Copyright © 2018 Riley Trautman + * + * ActivityStreams is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * ActivityStreams is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with ActivityStreams. If not, see . + */ + +pub use activitystreams_traits::Link; +pub use activitystreams_types::link::*; diff --git a/src/object.rs b/src/object.rs new file mode 100644 index 0000000..6a86c29 --- /dev/null +++ b/src/object.rs @@ -0,0 +1,21 @@ +/* + * This file is part of ActivityStreams. + * + * Copyright © 2018 Riley Trautman + * + * ActivityStreams is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * ActivityStreams is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with ActivityStreams. If not, see . + */ + +pub use activitystreams_traits::Object; +pub use activitystreams_types::object::*; diff --git a/src/properties.rs b/src/properties.rs index f7e6344..74e4aab 100644 --- a/src/properties.rs +++ b/src/properties.rs @@ -17,65 +17,4 @@ * along with ActivityStreams. If not, see . */ -use serde::{de::DeserializeOwned, ser::Serialize}; -use serde_json; - -use error::{Error, Result}; - -pub fn from_value(item: &serde_json::Value) -> Result -where - I: DeserializeOwned, -{ - serde_json::from_value(item.clone()).map_err(|_| Error::Deserialize) -} - -pub fn to_value(item: I) -> Result -where - I: Serialize, -{ - serde_json::to_value(item).map_err(|_| Error::Serialize) -} - -pub fn from_item(item: &Option) -> Result -where - I: DeserializeOwned, -{ - if let &Some(ref item) = item { - from_value(item) - } else { - Err(Error::NotFound) - } -} - -pub fn to_item(item: I) -> Result> -where - I: Serialize, -{ - to_value(item).map(Some) -} - -pub fn from_vec(v: &Vec) -> Result> -where - I: DeserializeOwned, -{ - v.iter().fold(Ok(Vec::new()), |acc, item| match acc { - Ok(mut acc) => from_value(item).map(|item| { - acc.push(item); - acc - }), - e => e, - }) -} - -pub fn to_vec(v: Vec) -> Result> -where - I: Serialize, -{ - v.into_iter().fold(Ok(Vec::new()), |acc, item| match acc { - Ok(mut acc) => to_value(item).map(|item| { - acc.push(item); - acc - }), - e => e, - }) -} +pub use activitystreams_traits::properties::*;