Reorganize into workspace

This commit is contained in:
asonix 2018-05-13 22:24:41 -05:00
parent bf4df5f760
commit 176fd0bc8f
68 changed files with 1029 additions and 546 deletions

View file

@ -1,6 +1,6 @@
[package] [package]
name = "activitystreams" name = "activitystreams"
description = "Derive macros for activitystreams" description = "Activity Streams in Rust"
version = "0.1.0" version = "0.1.0"
license = "GPL-3.0" license = "GPL-3.0"
authors = ["asonix <asonix.dev@gmail.com>"] authors = ["asonix <asonix.dev@gmail.com>"]
@ -8,10 +8,12 @@ repository = "https://github.com/asonix/activitystreams"
keywords = ["activitystreams", "activitypub"] keywords = ["activitystreams", "activitypub"]
[dependencies] [dependencies]
activitystreams-derive = { version = "0.1", path = "activitystreams-derive" } activitystreams-traits = { version = "0.1", path = "activitystreams-traits" }
chrono = { version = "0.4", features = ["serde"] } activitystreams-types = { version = "0.1", path = "activitystreams-types" }
failure = "0.1"
mime = "0.3" [workspace]
serde = "1.0" members = [
serde_derive = "1.0" "activitystreams-derive",
serde_json = "1.0" "activitystreams-traits",
"activitystreams-types",
]

View file

@ -224,7 +224,7 @@ pub fn properties_derive(input: TokenStream) -> TokenStream {
if is_concrete { if is_concrete {
if is_option { if is_option {
let single = quote! { let single_1 = quote! {
/// Retrieve a value from the given struct /// Retrieve a value from the given struct
/// ///
/// This method deserializes the item from JSON, so be wary of using /// 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 /// Possible errors from this method are `Error::NotFound` and
/// `Error::Deserialize` /// `Error::Deserialize`
pub fn #fn_name(&self) -> ::error::Result<#variant> { pub fn #fn_name(&self) -> ::activitystreams_traits::Result<#variant> {
::properties::from_item(&self.#ident) ::activitystreams_traits::properties::from_item(&self.#ident)
} }
};
let single_2 = quote! {
/// Set a value in the given struct /// Set a value in the given struct
/// ///
/// This method serializes the item to JSON, so be wary of using this a /// This method serializes the item to JSON, so be wary of using this a
/// lot. /// lot.
/// ///
/// Possible errors from this method are `Error::Serialize` /// Possible errors from this method are `Error::Serialize`
pub fn #set_fn_name(&mut self, item: #variant) -> ::error::Result<()> { pub fn #set_fn_name(&mut self, item: #variant) -> ::activitystreams_traits::Result<()> {
self.#ident = ::properties::to_item(item)?; self.#ident = ::activitystreams_traits::properties::to_item(item)?;
Ok(()) Ok(())
} }
}; };
let single = quote! {
#single_1
#single_2
};
if is_functional { if is_functional {
single single
} else { } else {
quote! { let plural_1 = quote! {
#single
/// Retrieve many values from the given struct /// Retrieve many values from the given struct
/// ///
/// This method deserializes the item from JSON, so be wary of using /// 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 /// Possible errors from this method are `Error::NotFound` and
/// `Error::Deserialize` /// `Error::Deserialize`
pub fn #fn_plural(&self) -> ::error::Result<Vec<#variant>> { pub fn #fn_plural(&self) -> ::activitystreams_traits::Result<Vec<#variant>> {
::properties::from_item(&self.#ident) ::activitystreams_traits::properties::from_item(&self.#ident)
} }
};
let plural_2 = quote! {
/// Set many values in the given struct /// Set many values in the given struct
/// ///
/// This method serializes the item to JSON, so be wary of using /// This method serializes the item to JSON, so be wary of using
/// this a lot. /// this a lot.
/// ///
/// Possible errors from this method are `Error::Serialize` /// Possible errors from this method are `Error::Serialize`
pub fn #set_fn_plural(&mut self, item: Vec<#variant>) -> ::error::Result<()> { pub fn #set_fn_plural(&mut self, item: Vec<#variant>) -> ::activitystreams_traits::Result<()> {
self.#ident = ::properties::to_item(item)?; self.#ident = ::activitystreams_traits::properties::to_item(item)?;
Ok(()) Ok(())
} }
};
quote! {
#single
#plural_1
#plural_2
} }
} }
} else if is_vec { } else if is_vec {
quote! { let single_1 = quote! {
/// Retrieve many values from the given struct /// Retrieve many values from the given struct
/// ///
/// This method deserializes the item from JSON, so be wary of using /// This method deserializes the item from JSON, so be wary of using
/// this a lot. /// this a lot.
/// ///
/// Possible errors from this method are `Error::Deserialize` /// Possible errors from this method are `Error::Deserialize`
pub fn #fn_name(&self) -> ::error::Result<Vec<#variant>> { pub fn #fn_name(&self) -> ::activitystreams_traits::Result<Vec<#variant>> {
::properties::from_vec(&self.#ident) ::activitystreams_traits::properties::from_vec(&self.#ident)
} }
};
let single_2 = quote! {
/// Set many values in the given struct /// Set many values in the given struct
/// ///
/// This method serializes the item to JSON, so be wary of using /// This method serializes the item to JSON, so be wary of using
/// this a lot. /// this a lot.
/// ///
/// Possible errors from this method are `Error::Serialize` /// Possible errors from this method are `Error::Serialize`
pub fn #set_fn_name(&mut self, item: Vec<#variant>>) -> ::error::Result<()> { pub fn #set_fn_name(&mut self, item: Vec<#variant>>) -> ::activitystreams_traits::Result<()> {
self.#ident = ::properties::to_vec(item)?; self.#ident = ::activitystreams_traits::properties::to_vec(item)?;
Ok(()) Ok(())
} }
};
quote! {
#single_1
#single_2
} }
} else { } else {
let single = quote! { let single = quote! {
@ -308,8 +328,8 @@ pub fn properties_derive(input: TokenStream) -> TokenStream {
/// this a lot. /// this a lot.
/// ///
/// Possible errors from this method are `Error::Deserialize` /// Possible errors from this method are `Error::Deserialize`
pub fn #fn_name(&self) -> ::error::Result<#variant> { pub fn #fn_name(&self) -> ::activitystreams_traits::Result<#variant> {
::properties::from_value(&self.#ident) ::activitystreams_traits::properties::from_value(&self.#ident)
} }
/// Set a value in the given struct /// Set a value in the given struct
@ -318,8 +338,8 @@ pub fn properties_derive(input: TokenStream) -> TokenStream {
/// lot. /// lot.
/// ///
/// Possible errors from this method are `Error::Serialize` /// Possible errors from this method are `Error::Serialize`
pub fn #set_fn_name(&mut self, item: #variant) -> ::error::Result<()> { pub fn #set_fn_name(&mut self, item: #variant) -> ::activitystreams_traits::Result<()> {
self.#ident = ::properties::to_value(item)?; self.#ident = ::activitystreams_traits::properties::to_value(item)?;
Ok(()) Ok(())
} }
}; };
@ -327,29 +347,35 @@ pub fn properties_derive(input: TokenStream) -> TokenStream {
if is_functional { if is_functional {
single single
} else { } else {
quote! { let plural_1 = quote! {
#single
/// Retrieve many values from the given struct /// Retrieve many values from the given struct
/// ///
/// This method deserializes the item from JSON, so be wary of using /// This method deserializes the item from JSON, so be wary of using
/// this a lot. /// this a lot.
/// ///
/// Possible errors from this method are `Error::Deserialize` /// Possible errors from this method are `Error::Deserialize`
pub fn #fn_plural(&self) -> ::error::Result<Vec<#variant>> { pub fn #fn_plural(&self) -> ::activitystreams_traits::Result<Vec<#variant>> {
::properties::from_value(&self.#ident) ::activitystreams_traits::properties::from_value(&self.#ident)
} }
};
let plural_2 = quote! {
/// Set many values in the given struct /// Set many values in the given struct
/// ///
/// This method serializes the item to JSON, so be wary of using this /// This method serializes the item to JSON, so be wary of using this
/// a lot. /// a lot.
/// ///
/// Possible errors from this method are `Error::Serialize` /// Possible errors from this method are `Error::Serialize`
pub #set_fn_plural(&mut self, item: Vec<#variant>) -> ::error::Result<()> { pub #set_fn_plural(&mut self, item: Vec<#variant>) -> ::activitystreams_traits::Result<()> {
self.#ident = ::properties::to_value(item)?; self.#ident = ::activitystreams_traits::properties::to_value(item)?;
Ok(()) 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 /// Possible errors from this method are `Error::NotFound` and
/// `Error::Deserialize` /// `Error::Deserialize`
pub fn #fn_name<T: #variant>(&self) -> ::error::Result<T> { pub fn #fn_name<T: #variant>(&self) -> ::activitystreams_traits::Result<T> {
::properties::from_item(&self.#ident) ::activitystreams_traits::properties::from_item(&self.#ident)
} }
}; };
@ -374,8 +400,8 @@ pub fn properties_derive(input: TokenStream) -> TokenStream {
/// lot. /// lot.
/// ///
/// Possible errors from this method are `Error::Serialize` /// Possible errors from this method are `Error::Serialize`
pub fn #set_fn_name<T: #variant>(&mut self, item: T) -> ::error::Result<()> { pub fn #set_fn_name<T: #variant>(&mut self, item: T) -> ::activitystreams_traits::Result<()> {
self.#ident = ::properties::to_item(item)?; self.#ident = ::activitystreams_traits::properties::to_item(item)?;
Ok(()) Ok(())
} }
}; };
@ -396,8 +422,8 @@ pub fn properties_derive(input: TokenStream) -> TokenStream {
/// ///
/// Possible errors from this method are `Error::NotFound` and /// Possible errors from this method are `Error::NotFound` and
/// `Error::Deserialize` /// `Error::Deserialize`
pub fn #fn_plural<T: #variant>(&self) -> ::error::Result<Vec<T>> { pub fn #fn_plural<T: #variant>(&self) -> ::activitystreams_traits::Result<Vec<T>> {
::properties::from_item(&self.#ident) ::activitystreams_traits::properties::from_item(&self.#ident)
} }
}; };
@ -408,8 +434,8 @@ pub fn properties_derive(input: TokenStream) -> TokenStream {
/// this a lot. /// this a lot.
/// ///
/// Possible errors from this method are `Error::Serialize` /// Possible errors from this method are `Error::Serialize`
pub fn #set_fn_plural<T: #variant>(&mut self, item: Vec<T>) -> ::error::Result<()> { pub fn #set_fn_plural<T: #variant>(&mut self, item: Vec<T>) -> ::activitystreams_traits::Result<()> {
self.#ident = ::properties::to_item(item)?; self.#ident = ::activitystreams_traits::properties::to_item(item)?;
Ok(()) Ok(())
} }
}; };
@ -428,8 +454,8 @@ pub fn properties_derive(input: TokenStream) -> TokenStream {
/// this a lot. /// this a lot.
/// ///
/// Possible errors from this method are `Error::Deserialize` /// Possible errors from this method are `Error::Deserialize`
pub fn #fn_name<T: #variant>(&self) -> ::error::Result<Vec<T>> { pub fn #fn_name<T: #variant>(&self) -> ::activitystreams_traits::Result<Vec<T>> {
::properties::from_vec(&self.#ident) ::activitystreams_traits::properties::from_vec(&self.#ident)
} }
}; };
@ -440,8 +466,8 @@ pub fn properties_derive(input: TokenStream) -> TokenStream {
/// this a lot. /// this a lot.
/// ///
/// Possible errors from this method are `Error::Serialize` /// Possible errors from this method are `Error::Serialize`
pub fn #set_fn_name<T: #variant>(&mut self, item: Vec<T>) -> ::error::Result<()> { pub fn #set_fn_name<T: #variant>(&mut self, item: Vec<T>) -> ::activitystreams_traits::Result<()> {
self.#ident = ::properties::to_vec(item)?; self.#ident = ::activitystreams_traits::properties::to_vec(item)?;
Ok(()) Ok(())
} }
}; };
@ -458,8 +484,8 @@ pub fn properties_derive(input: TokenStream) -> TokenStream {
/// this a lot. /// this a lot.
/// ///
/// Possible errors from this method are `Error::Deserialize` /// Possible errors from this method are `Error::Deserialize`
pub fn #fn_name<T: #variant>(&self) -> ::error::Result<T> { pub fn #fn_name<T: #variant>(&self) -> ::activitystreams_traits::Result<T> {
::properties::from_value(&self.#ident) ::activitystreams_traits::properties::from_value(&self.#ident)
} }
}; };
@ -470,8 +496,8 @@ pub fn properties_derive(input: TokenStream) -> TokenStream {
/// lot. /// lot.
/// ///
/// Possible errors from this method are `Error::Serialize` /// Possible errors from this method are `Error::Serialize`
pub fn #set_fn_name<T: #variant>(&mut self, item: T) -> ::error::Result<()> { pub fn #set_fn_name<T: #variant>(&mut self, item: T) -> ::activitystreams_traits::Result<()> {
self.#ident = ::properties::to_value(item)?; self.#ident = ::activitystreams_traits::properties::to_value(item)?;
Ok(()) Ok(())
} }
}; };
@ -491,8 +517,8 @@ pub fn properties_derive(input: TokenStream) -> TokenStream {
/// this a lot. /// this a lot.
/// ///
/// Possible errors from this method are `Error::Deserialize` /// Possible errors from this method are `Error::Deserialize`
pub fn #fn_plural<T: #variant>(&self) -> ::error::Result<Vec<T>> { pub fn #fn_plural<T: #variant>(&self) -> ::activitystreams_traits::Result<Vec<T>> {
::properties::from_value(&self.#ident) ::activitystreams_traits::properties::from_value(&self.#ident)
} }
}; };
@ -503,8 +529,8 @@ pub fn properties_derive(input: TokenStream) -> TokenStream {
/// a lot. /// a lot.
/// ///
/// Possible errors from this method are `Error::Serialize` /// Possible errors from this method are `Error::Serialize`
pub fn #set_fn_plural<T: #variant>(&mut self, item: Vec<T>) -> ::error::Result<()> { pub fn #set_fn_plural<T: #variant>(&mut self, item: Vec<T>) -> ::activitystreams_traits::Result<()> {
self.#ident = ::properties::to_value(item)?; self.#ident = ::activitystreams_traits::properties::to_value(item)?;
Ok(()) Ok(())
} }
}; };

3
activitystreams-traits/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
/target
**/*.rs.bk
Cargo.lock

View file

@ -0,0 +1,13 @@
[package]
name = "activitystreams-traits"
description = "Traits for ActivityStreams objects"
version = "0.1.0"
license = "GPL-3.0"
authors = ["asonix <asonix.dev@gmail.com>"]
repository = "https://github.com/asonix/activitystreams"
keywords = ["activitystreams", "activitypub"]
[dependencies]
failure = "0.1"
serde = "1.0"
serde_json = "1.0"

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
use object::Object;
pub trait Activity: Object {}
pub trait IntransitiveActivity: Activity {}

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
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 {}

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
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 {}

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
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<T, Error>
pub type Result<T> = result::Result<T, Error>;

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#[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::*;

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
use serde::{de::DeserializeOwned, ser::Serialize};
/// The Link is the secondary base type for the Activity Streams vocabulary.
pub trait Link: DeserializeOwned + Serialize {}

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
use serde::{de::DeserializeOwned, ser::Serialize};
/// The Object is the primary base type for the Activity Streams vocabulary.
pub trait Object: DeserializeOwned + Serialize {}

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
//! 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<I>(item: &serde_json::Value) -> Result<I>
where
I: DeserializeOwned,
{
serde_json::from_value(item.clone()).map_err(|_| Error::Deserialize)
}
/// Serialize concrete type I into a `Value`
pub fn to_value<I>(item: I) -> Result<serde_json::Value>
where
I: Serialize,
{
serde_json::to_value(item).map_err(|_| Error::Serialize)
}
/// Deserialize an `Option<Value>` into concrete type I
pub fn from_item<I>(item: &Option<serde_json::Value>) -> Result<I>
where
I: DeserializeOwned,
{
if let &Some(ref item) = item {
from_value(item)
} else {
Err(Error::NotFound)
}
}
/// Serialize concrete type I into an `Option<Value>`
pub fn to_item<I>(item: I) -> Result<Option<serde_json::Value>>
where
I: Serialize,
{
to_value(item).map(Some)
}
/// Deserialize a `Vec<Value>` into a `Vec<I>`
pub fn from_vec<I>(v: &Vec<serde_json::Value>) -> Result<Vec<I>>
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<I>` into a `Vec<Value>`
pub fn to_vec<I>(v: Vec<I>) -> Result<Vec<serde_json::Value>>
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,
})
}

View file

@ -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 <asonix.dev@gmail.com>"]
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"

View file

@ -1,28 +1,27 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_traits::{Activity, Link, Object};
use serde_json; use serde_json;
use super::{kind::AcceptType, properties::ActivityProperties, Activity}; use super::{kind::AcceptType, properties::ActivityProperties};
use object::properties::ObjectProperties;
use link::Link;
use object::{properties::ObjectProperties, Object};
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -1,28 +1,27 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_traits::{Activity, Link, Object};
use serde_json; use serde_json;
use super::{kind::AddType, properties::ActivityProperties, Activity}; use super::{kind::AddType, properties::ActivityProperties};
use object::properties::ObjectProperties;
use link::Link;
use object::{properties::ObjectProperties, Object};
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -1,28 +1,27 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_traits::{Activity, Link, Object};
use serde_json; use serde_json;
use super::{kind::MoveType, properties::ActivityProperties, Activity}; use super::{kind::MoveType, properties::ActivityProperties};
use object::properties::ObjectProperties;
use link::Link;
use object::{properties::ObjectProperties, Object};
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -1,28 +1,27 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_traits::{Activity, Link, Object};
use serde_json; use serde_json;
use super::{kind::AnnounceType, properties::ActivityProperties, Activity}; use super::{kind::AnnounceType, properties::ActivityProperties};
use object::properties::ObjectProperties;
use link::Link;
use object::{properties::ObjectProperties, Object};
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -1,28 +1,27 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_traits::{Activity, IntransitiveActivity, Link, Object};
use serde_json; use serde_json;
use super::{kind::ArriveType, properties::ActivityProperties, Activity, IntransitiveActivity}; use super::{kind::ArriveType, properties::ActivityProperties};
use object::properties::ObjectProperties;
use link::Link;
use object::{properties::ObjectProperties, Object};
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -1,28 +1,27 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_traits::{Activity, Link, Object};
use serde_json; use serde_json;
use super::{kind::BlockType, properties::ActivityProperties, Activity}; use super::{kind::BlockType, properties::ActivityProperties};
use object::properties::ObjectProperties;
use link::Link;
use object::{properties::ObjectProperties, Object};
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -1,28 +1,27 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_traits::{Activity, Link, Object};
use serde_json; use serde_json;
use super::{kind::CreateType, properties::ActivityProperties, Activity}; use super::{kind::CreateType, properties::ActivityProperties};
use object::properties::ObjectProperties;
use link::Link;
use object::{properties::ObjectProperties, Object};
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -1,28 +1,27 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_traits::{Activity, Link, Object};
use serde_json; use serde_json;
use super::{kind::DeleteType, properties::ActivityProperties, Activity}; use super::{kind::DeleteType, properties::ActivityProperties};
use object::properties::ObjectProperties;
use link::Link;
use object::{properties::ObjectProperties, Object};
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -1,28 +1,27 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_traits::{Activity, Link, Object};
use serde_json; use serde_json;
use super::{kind::DislikeType, properties::ActivityProperties, Activity}; use super::{kind::DislikeType, properties::ActivityProperties};
use object::properties::ObjectProperties;
use link::Link;
use object::{properties::ObjectProperties, Object};
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -1,28 +1,27 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_traits::{Activity, Link, Object};
use serde_json; use serde_json;
use super::{kind::FlagType, properties::ActivityProperties, Activity}; use super::{kind::FlagType, properties::ActivityProperties};
use object::properties::ObjectProperties;
use link::Link;
use object::{properties::ObjectProperties, Object};
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -1,28 +1,27 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_traits::{Activity, Link, Object};
use serde_json; use serde_json;
use super::{kind::FollowType, properties::ActivityProperties, Activity}; use super::{kind::FollowType, properties::ActivityProperties};
use object::properties::ObjectProperties;
use link::Link;
use object::{properties::ObjectProperties, Object};
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -1,28 +1,27 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_traits::{Activity, Link, Object};
use serde_json; use serde_json;
use super::{kind::IgnoreType, properties::ActivityProperties, Activity}; use super::{kind::IgnoreType, properties::ActivityProperties};
use object::properties::ObjectProperties;
use link::Link;
use object::{properties::ObjectProperties, Object};
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -1,28 +1,27 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_traits::{Activity, Link, Object};
use serde_json; use serde_json;
use super::{kind::InviteType, properties::ActivityProperties, Activity}; use super::{kind::InviteType, properties::ActivityProperties};
use object::properties::ObjectProperties;
use link::Link;
use object::{properties::ObjectProperties, Object};
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -1,28 +1,27 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_traits::{Activity, Link, Object};
use serde_json; use serde_json;
use super::{kind::JoinType, properties::ActivityProperties, Activity}; use super::{kind::JoinType, properties::ActivityProperties};
use object::properties::ObjectProperties;
use link::Link;
use object::{properties::ObjectProperties, Object};
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -1,20 +1,20 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use std::fmt; use std::fmt;

View file

@ -1,28 +1,27 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_traits::{Activity, Link, Object};
use serde_json; use serde_json;
use super::{kind::LeaveType, properties::ActivityProperties, Activity}; use super::{kind::LeaveType, properties::ActivityProperties};
use object::properties::ObjectProperties;
use link::Link;
use object::{properties::ObjectProperties, Object};
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -1,28 +1,27 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_traits::{Activity, Link, Object};
use serde_json; use serde_json;
use super::{kind::LikeType, properties::ActivityProperties, Activity}; use super::{kind::LikeType, properties::ActivityProperties};
use object::properties::ObjectProperties;
use link::Link;
use object::{properties::ObjectProperties, Object};
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -1,28 +1,27 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_traits::{Activity, Link, Object};
use serde_json; use serde_json;
use super::{kind::ListenType, properties::ActivityProperties, Activity}; use super::{kind::ListenType, properties::ActivityProperties};
use object::properties::ObjectProperties;
use link::Link;
use object::{properties::ObjectProperties, Object};
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -1,24 +1,22 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use object::Object;
mod accept; mod accept;
mod add; mod add;
mod amove; mod amove;
@ -79,6 +77,3 @@ pub use self::travel::*;
pub use self::undo::*; pub use self::undo::*;
pub use self::update::*; pub use self::update::*;
pub use self::view::*; pub use self::view::*;
pub trait Activity: Object {}
pub trait IntransitiveActivity: Activity {}

View file

@ -1,28 +1,27 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_traits::{Activity, Link, Object};
use serde_json; use serde_json;
use super::{kind::OfferType, properties::ActivityProperties, Activity}; use super::{kind::OfferType, properties::ActivityProperties};
use object::properties::ObjectProperties;
use link::Link;
use object::{properties::ObjectProperties, Object};
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -1,27 +1,25 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_traits::{Link, Object};
use serde_json; use serde_json;
use link::Link;
use object::Object;
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct ActivityProperties { pub struct ActivityProperties {

View file

@ -1,28 +1,27 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_traits::{Activity, IntransitiveActivity, Link, Object};
use serde_json; use serde_json;
use super::{kind::QuestionType, properties::ActivityProperties, Activity, IntransitiveActivity}; use super::{kind::QuestionType, properties::ActivityProperties};
use object::properties::ObjectProperties;
use link::Link;
use object::{properties::ObjectProperties, Object};
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -1,28 +1,27 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_traits::{Activity, Link, Object};
use serde_json; use serde_json;
use super::{kind::ReadType, properties::ActivityProperties, Activity}; use super::{kind::ReadType, properties::ActivityProperties};
use object::properties::ObjectProperties;
use link::Link;
use object::{properties::ObjectProperties, Object};
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -1,28 +1,27 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_traits::{Activity, Link, Object};
use serde_json; use serde_json;
use super::{kind::RejectType, properties::ActivityProperties, Activity}; use super::{kind::RejectType, properties::ActivityProperties};
use object::properties::ObjectProperties;
use link::Link;
use object::{properties::ObjectProperties, Object};
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -1,28 +1,27 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_traits::{Activity, Link, Object};
use serde_json; use serde_json;
use super::{kind::RemoveType, properties::ActivityProperties, Activity}; use super::{kind::RemoveType, properties::ActivityProperties};
use object::properties::ObjectProperties;
use link::Link;
use object::{properties::ObjectProperties, Object};
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -1,28 +1,27 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_traits::{Activity, Link, Object};
use serde_json; use serde_json;
use super::{kind::TentativeAcceptType, properties::ActivityProperties, Activity}; use super::{kind::TentativeAcceptType, properties::ActivityProperties};
use object::properties::ObjectProperties;
use link::Link;
use object::{properties::ObjectProperties, Object};
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -1,28 +1,27 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_traits::{Activity, Link, Object};
use serde_json; use serde_json;
use super::{kind::TentativeRejectType, properties::ActivityProperties, Activity}; use super::{kind::TentativeRejectType, properties::ActivityProperties};
use object::properties::ObjectProperties;
use link::Link;
use object::{properties::ObjectProperties, Object};
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -1,28 +1,27 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_traits::{Activity, IntransitiveActivity, Link, Object};
use serde_json; use serde_json;
use super::{kind::TravelType, properties::ActivityProperties, Activity, IntransitiveActivity}; use super::{kind::TravelType, properties::ActivityProperties};
use object::properties::ObjectProperties;
use link::Link;
use object::{properties::ObjectProperties, Object};
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -1,28 +1,27 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_traits::{Activity, Link, Object};
use serde_json; use serde_json;
use super::{kind::UndoType, properties::ActivityProperties, Activity}; use super::{kind::UndoType, properties::ActivityProperties};
use object::properties::ObjectProperties;
use link::Link;
use object::{properties::ObjectProperties, Object};
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -1,28 +1,27 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_traits::{Activity, Link, Object};
use serde_json; use serde_json;
use super::{kind::UpdateType, properties::ActivityProperties, Activity}; use super::{kind::UpdateType, properties::ActivityProperties};
use object::properties::ObjectProperties;
use link::Link;
use object::{properties::ObjectProperties, Object};
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -1,28 +1,27 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use activitystreams_traits::{Activity, Link, Object};
use serde_json; use serde_json;
use super::{kind::ViewType, properties::ActivityProperties, Activity}; use super::{kind::ViewType, properties::ActivityProperties};
use object::properties::ObjectProperties;
use link::Link;
use object::{properties::ObjectProperties, Object};
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -1,22 +1,24 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
//! Namespace for Unit Structs that serialize to strings
use std::fmt; use std::fmt;
use serde::{ use serde::{

View file

@ -1,85 +1,102 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use object::{properties::ObjectProperties, Object}; //! Namespace for Actor types
use activitystreams_traits::{Actor, Object};
use object::properties::ObjectProperties;
mod kind; mod kind;
pub use self::kind::*; pub use self::kind::*;
pub trait Actor: Object {} /// Describes a software application.
#[derive(Clone, Debug, Default, Deserialize, Serialize)] #[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct Appliation { pub struct Appliation {
#[serde(rename = "type")] #[serde(rename = "type")]
kind: ApplicationType, kind: ApplicationType,
/// Adds all valid object properties to this struct
#[serde(flatten)] #[serde(flatten)]
pub object_props: ObjectProperties, pub object_props: ObjectProperties,
} }
impl Object for Appliation {} impl Object for Appliation {}
impl Actor for Appliation {}
/// Represents a formal or informal collective of Actors.
#[derive(Clone, Debug, Default, Deserialize, Serialize)] #[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct Group { pub struct Group {
#[serde(rename = "type")] #[serde(rename = "type")]
kind: GroupType, kind: GroupType,
/// Adds all valid object properties to this struct
#[serde(flatten)] #[serde(flatten)]
pub object_props: ObjectProperties, pub object_props: ObjectProperties,
} }
impl Object for Group {} impl Object for Group {}
impl Actor for Group {}
/// Represents an organization.
#[derive(Clone, Debug, Default, Deserialize, Serialize)] #[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct Organization { pub struct Organization {
#[serde(rename = "type")] #[serde(rename = "type")]
kind: OrganizationType, kind: OrganizationType,
/// Adds all valid object properties to this struct
#[serde(flatten)] #[serde(flatten)]
pub object_props: ObjectProperties, pub object_props: ObjectProperties,
} }
impl Object for Organization {} impl Object for Organization {}
impl Actor for Organization {}
/// Represents an individual person.
#[derive(Clone, Debug, Default, Deserialize, Serialize)] #[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct Person { pub struct Person {
#[serde(rename = "type")] #[serde(rename = "type")]
kind: PersonType, kind: PersonType,
/// Adds all valid object properties to this struct
#[serde(flatten)] #[serde(flatten)]
pub object_props: ObjectProperties, pub object_props: ObjectProperties,
} }
impl Object for Person {} impl Object for Person {}
impl Actor for Person {}
/// Represents a service of any kind.
#[derive(Clone, Debug, Default, Deserialize, Serialize)] #[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct Service { pub struct Service {
#[serde(rename = "type")] #[serde(rename = "type")]
kind: ServiceType, kind: ServiceType,
/// Adds all valid object properties to this struct
#[serde(flatten)] #[serde(flatten)]
pub object_props: ObjectProperties, pub object_props: ObjectProperties,
} }
impl Object for Service {} impl Object for Service {}
impl Actor for Service {}

View file

@ -1,22 +1,24 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
//! Namespace for Unit Structs that serialize to strings
use std::fmt; use std::fmt;
use serde::{ use serde::{

View file

@ -1,35 +1,33 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use object::{properties::ObjectProperties, Object}; //! Namespace for Collection types
use activitystreams_traits::{Collection, CollectionPage, Object};
use object::properties::ObjectProperties;
pub mod kind; pub mod kind;
pub mod properties; pub mod properties;
use self::kind::*; use self::kind::*;
use self::properties::*; 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)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct UnorderedCollection { pub struct UnorderedCollection {
@ -90,6 +88,7 @@ pub struct UnorderedCollectionPage {
impl Object for UnorderedCollectionPage {} impl Object for UnorderedCollectionPage {}
impl Collection for UnorderedCollectionPage {} impl Collection for UnorderedCollectionPage {}
impl CollectionPage for UnorderedCollectionPage {}
/// Used to represent ordered subsets of items from an `OrderedCollection`. /// Used to represent ordered subsets of items from an `OrderedCollection`.
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
@ -117,3 +116,4 @@ pub struct OrderedCollectionPage {
impl Object for OrderedCollectionPage {} impl Object for OrderedCollectionPage {}
impl Collection for OrderedCollectionPage {} impl Collection for OrderedCollectionPage {}
impl CollectionPage for OrderedCollectionPage {}

View file

@ -1,20 +1,20 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
//! Namespace for properties of standard object types //! Namespace for properties of standard object types
@ -56,14 +56,9 @@
//! # fn main() {} //! # fn main() {}
//! ``` //! ```
use activitystreams_traits::{Collection, CollectionPage, Link, Object};
use serde_json; 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 /// `Collection` objects are a specialization of the base `Object` that serve as a container for
/// other `Objects` or `Links`. /// 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 /// In a paged `Collection`, indicates the page that contains the most recently updated member
/// items. /// items.
/// ///
/// - Range: `CollectionPage` | `OrderedCollectionPage` | `Link` /// - Range: `CollectionPage` | `Link`
/// - Functional: true /// - Functional: true
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
#[activitystreams( #[activitystreams(ab(Link, CollectionPage), functional)]
concrete(UnorderedCollectionPage, OrderedCollectionPage), ab(Link), functional
)]
pub current: Option<serde_json::Value>, pub current: Option<serde_json::Value>,
/// In a paged `Collection`, indicates the furthest preceeding page of items in the collection. /// In a paged `Collection`, indicates the furthest preceeding page of items in the collection.
/// ///
/// - Range: `CollectionPage` | `OrderedCollectionPage` | `Link` /// - Range: `CollectionPage` | `Link`
/// - Functional: true /// - Functional: true
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
#[activitystreams( #[activitystreams(ab(Link, CollectionPage), functional)]
concrete(UnorderedCollectionPage, OrderedCollectionPage), ab(Link), functional
)]
pub first: Option<serde_json::Value>, pub first: Option<serde_json::Value>,
/// In a paged `Collection`, indicates the furthest proceeding page of the collection. /// In a paged `Collection`, indicates the furthest proceeding page of the collection.
/// ///
/// - Range: `CollectionPage` | `OrderedCollectionPage` | `Link` /// - Range: `CollectionPage` | `Link`
/// - Functional: true /// - Functional: true
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
#[activitystreams( #[activitystreams(ab(Link, CollectionPage), functional)]
concrete(UnorderedCollectionPage, OrderedCollectionPage), ab(Link), functional
)]
pub last: Option<serde_json::Value>, pub last: Option<serde_json::Value>,
} }
@ -132,26 +121,26 @@ pub struct CollectionProperties {
pub struct CollectionPageProperties { pub struct CollectionPageProperties {
/// Identifies the `Collection` to which a `CollectionPage` objects items belong. /// Identifies the `Collection` to which a `CollectionPage` objects items belong.
/// ///
/// Range: `Collection` | `OrderedCollection` | `Link` /// Range: `Collection` | `Link`
/// Functional: true /// Functional: true
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
#[activitystreams(concrete(UnorderedCollection, OrderedCollection), ab(Link), functional)] #[activitystreams(ab(Link, Collection), functional)]
pub part_of: Option<serde_json::Value>, pub part_of: Option<serde_json::Value>,
/// In a paged `Collection`, indicates the next page of items. /// In a paged `Collection`, indicates the next page of items.
/// ///
/// - Range: `CollectionPage` | `OrderedCollectionPage` | `Link` /// - Range: `CollectionPage` | `Link`
/// - Functional: true /// - Functional: true
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
#[activitystreams(concrete(UnorderedCollectionPage), ab(Link), functional)] #[activitystreams(ab(Link, CollectionPage), functional)]
pub next: Option<serde_json::Value>, pub next: Option<serde_json::Value>,
/// In a paged `Collection`, identifies the previous page of items. /// In a paged `Collection`, identifies the previous page of items.
/// ///
/// - Range: `CollectionPage` | `OrderedCollectionPage` | `Link` /// - Range: `CollectionPage` | `Link`
/// - Functional: true /// - Functional: true
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
#[activitystreams(concrete(UnorderedCollectionPage), ab(Link), functional)] #[activitystreams(ab(Link, CollectionPage), functional)]
pub prev: Option<serde_json::Value>, pub prev: Option<serde_json::Value>,
} }

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
//! 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<C, L> {
#[serde(flatten)]
pub link: L,
#[serde(flatten)]
pub custom_props: C,
}
impl<C, L: Link> CustomLink<C, L> {
pub fn new(link: L, custom_props: C) -> Self {
CustomLink { link, custom_props }
}
}
impl<C, L> Link for CustomLink<C, L>
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<C, O> {
#[serde(flatten)]
pub object: O,
#[serde(flatten)]
pub custom_props: C,
}
impl<C, O: Object> CustomObject<C, O> {
pub fn new(object: O, custom_props: C) -> Self {
CustomObject {
object,
custom_props,
}
}
}
impl<C, O> Object for CustomObject<C, O>
where
C: DeserializeOwned + Serialize,
O: Object,
{
}
impl<C, O> Actor for CustomObject<C, O>
where
C: DeserializeOwned + Serialize,
O: Actor,
{
}
impl<C, O> Collection for CustomObject<C, O>
where
C: DeserializeOwned + Serialize,
O: Collection,
{
}
impl<C, O> CollectionPage for CustomObject<C, O>
where
C: DeserializeOwned + Serialize,
O: CollectionPage,
{
}
impl<C, O> Activity for CustomObject<C, O>
where
C: DeserializeOwned + Serialize,
O: Activity,
{
}
impl<C, O> IntransitiveActivity for CustomObject<C, O>
where
C: DeserializeOwned + Serialize,
O: IntransitiveActivity,
{
}

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#[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};

View file

@ -1,20 +1,20 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
//! Namespace for Unit Structs that serialize to strings //! Namespace for Unit Structs that serialize to strings

View file

@ -1,32 +1,31 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
use serde::{de::DeserializeOwned, ser::Serialize}; //! Namespace for Link types
use activitystreams_traits::Link;
pub mod kind; pub mod kind;
pub mod properties; pub mod properties;
use self::kind::*; use self::kind::*;
use self::properties::*; 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. /// A specialized Link that represents an @mention.
#[derive(Clone, Debug, Default, Deserialize, Serialize)] #[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -1,20 +1,20 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
//! Namespace for properties of standard link types //! Namespace for properties of standard link types
@ -47,13 +47,10 @@
//! # fn main() {} //! # fn main() {}
//! ``` //! ```
use activitystreams_traits::{Error, Link, Object, Result};
use mime; use mime;
use serde_json; 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 /// Define all the properties of the Object base type as described by the Activity Streams
/// vocabulary. /// vocabulary.
/// ///

View file

@ -1,20 +1,20 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
//! Namespace for Unit Structs that serialize to strings //! Namespace for Unit Structs that serialize to strings

View file

@ -1,34 +1,31 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
//! Namespace for Object types //! Namespace for Object types
use serde::{de::DeserializeOwned, ser::Serialize}; use activitystreams_traits::Object;
pub mod kind; pub mod kind;
pub mod properties; pub mod properties;
use self::kind::*; use self::kind::*;
use self::properties::*; 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. /// Represents any kind of multi-paragraph written work.
#[derive(Clone, Debug, Default, Deserialize, Serialize)] #[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -1,20 +1,20 @@
/* /*
* This file is part of ActivityStreams. * This file is part of ActivityStreams Types.
* *
* Copyright © 2018 Riley Trautman * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
*/ */
//! Namespace for properties of standard object types //! Namespace for properties of standard object types
@ -47,14 +47,12 @@
//! # fn main() {} //! # fn main() {}
//! ``` //! ```
use activitystreams_traits::{Collection, Error, Link, Object, Result};
use chrono::{offset::Utc, DateTime}; use chrono::{offset::Utc, DateTime};
use mime; use mime;
use serde_json; use serde_json;
use collection::Collection; use object::Image;
use error::{Error, Result};
use link::Link;
use object::{Image, Object};
/// Alias chrono::DateTime<Utc> for use in derive macros /// Alias chrono::DateTime<Utc> for use in derive macros
pub type UtcTime = DateTime<Utc>; pub type UtcTime = DateTime<Utc>;

21
src/activity.rs Normal file
View file

@ -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 <http://www.gnu.org/licenses/>.
*/
pub use activitystreams_traits::{Activity, IntransitiveActivity};
pub use activitystreams_types::activity::*;

21
src/actor.rs Normal file
View file

@ -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 <http://www.gnu.org/licenses/>.
*/
pub use activitystreams_traits::Actor;
pub use activitystreams_types::actor::*;

21
src/collection.rs Normal file
View file

@ -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 <http://www.gnu.org/licenses/>.
*/
pub use activitystreams_traits::{Collection, CollectionPage};
pub use activitystreams_types::collection::*;

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
use link::Link;
use object::Object;
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CustomLink<C, L> {
#[serde(flatten)]
pub link: L,
#[serde(flatten)]
pub custom_props: C,
}
impl<C, L: Link> CustomLink<C, L> {
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<C, O> {
#[serde(flatten)]
pub object: O,
#[serde(flatten)]
pub custom_props: C,
}
impl<C, O: Object> CustomObject<C, O> {
pub fn new(object: O, custom_props: C) -> Self {
CustomObject {
object,
custom_props,
}
}
}

View file

@ -17,18 +17,4 @@
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>.
*/ */
use std::result; pub use activitystreams_traits::{Error, 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<T> = result::Result<T, Error>;

View file

@ -17,28 +17,12 @@
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>.
*/ */
#[macro_use] extern crate activitystreams_traits;
extern crate activitystreams_derive; extern crate activitystreams_types;
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",
})
}
pub mod activity; pub mod activity;
pub mod actor; pub mod actor;
pub mod collection; pub mod collection;
pub mod custom_props;
pub mod error; pub mod error;
pub mod link; pub mod link;
pub mod object; pub mod object;
@ -47,7 +31,6 @@ pub mod properties;
pub use self::activity::{Activity, IntransitiveActivity}; pub use self::activity::{Activity, IntransitiveActivity};
pub use self::actor::Actor; pub use self::actor::Actor;
pub use self::collection::{Collection, CollectionPage}; pub use self::collection::{Collection, CollectionPage};
pub use self::custom_props::{CustomLink, CustomObject};
pub use self::error::Error; pub use self::error::Error;
pub use self::link::Link; pub use self::link::Link;
pub use self::object::Object; pub use self::object::Object;

21
src/link.rs Normal file
View file

@ -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 <http://www.gnu.org/licenses/>.
*/
pub use activitystreams_traits::Link;
pub use activitystreams_types::link::*;

21
src/object.rs Normal file
View file

@ -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 <http://www.gnu.org/licenses/>.
*/
pub use activitystreams_traits::Object;
pub use activitystreams_types::object::*;

View file

@ -17,65 +17,4 @@
* along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>. * along with ActivityStreams. If not, see <http://www.gnu.org/licenses/>.
*/ */
use serde::{de::DeserializeOwned, ser::Serialize}; pub use activitystreams_traits::properties::*;
use serde_json;
use error::{Error, Result};
pub fn from_value<I>(item: &serde_json::Value) -> Result<I>
where
I: DeserializeOwned,
{
serde_json::from_value(item.clone()).map_err(|_| Error::Deserialize)
}
pub fn to_value<I>(item: I) -> Result<serde_json::Value>
where
I: Serialize,
{
serde_json::to_value(item).map_err(|_| Error::Serialize)
}
pub fn from_item<I>(item: &Option<serde_json::Value>) -> Result<I>
where
I: DeserializeOwned,
{
if let &Some(ref item) = item {
from_value(item)
} else {
Err(Error::NotFound)
}
}
pub fn to_item<I>(item: I) -> Result<Option<serde_json::Value>>
where
I: Serialize,
{
to_value(item).map(Some)
}
pub fn from_vec<I>(v: &Vec<serde_json::Value>) -> Result<Vec<I>>
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<I>(v: Vec<I>) -> Result<Vec<serde_json::Value>>
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,
})
}