diff --git a/Cargo.toml b/Cargo.toml index f3dd495..340492f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "activitystreams" description = "Activity Streams in Rust" -version = "0.5.0-alpha.3" +version = "0.5.0-alpha.4" license = "GPL-3.0" authors = ["asonix "] repository = "https://git.asonix.dog/Aardwolf/activitystreams" @@ -17,7 +17,7 @@ primitives = ["chrono", "mime", "serde", "thiserror", "url"] types = ["derive", "kinds", "primitives", "serde", "serde_json"] [dependencies] -activitystreams-derive = { version = "0.5.0-alpha.2", path = "activitystreams-derive", optional = true} +activitystreams-derive = { version = "0.5.0-alpha.3", path = "activitystreams-derive", optional = true} chrono = { version = "0.4", optional = true } mime = { version = "0.3", optional = true } serde = { version = "1.0", features = ["derive"], optional = true } diff --git a/README.md b/README.md index 06a4837..a396dfb 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ __A set of Traits and Types that make up the ActivityStreams and ActivityPub spe First, add ActivityStreams to your dependencies ```toml -activitystreams = "0.5.0-alpha.3" +activitystreams = "0.5.0-alpha.4" ``` ### Types @@ -177,7 +177,7 @@ There are a number of features that can be disabled in this crate. By default, e enabled. ```toml -activitystreams = { version = "0.5.0-alpha.0", default-features = "false", features = ["derive"] } +activitystreams = { version = "0.5.0-alpha.4", default-features = "false", features = ["derive"] } ``` | feature | what you get | diff --git a/activitystreams-derive/Cargo.toml b/activitystreams-derive/Cargo.toml index 2a7a652..93698bd 100644 --- a/activitystreams-derive/Cargo.toml +++ b/activitystreams-derive/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "activitystreams-derive" description = "Derive macros for activitystreams" -version = "0.5.0-alpha.2" +version = "0.5.0-alpha.3" license = "GPL-3.0" authors = ["asonix "] repository = "https://git.asonix.dog/Aardwolf/activitystreams" diff --git a/activitystreams-derive/README.md b/activitystreams-derive/README.md index 2716e89..f5f92f4 100644 --- a/activitystreams-derive/README.md +++ b/activitystreams-derive/README.md @@ -10,7 +10,7 @@ Add the required crates to your `Cargo.toml` ```toml # Cargo.toml -activitystreams = "0.5.0-alpha.3" +activitystreams = "0.5.0-alpha.4" serde = { version = "1.0", features = ["derive"] } ``` diff --git a/activitystreams-derive/src/lib.rs b/activitystreams-derive/src/lib.rs index eb5fe47..d9b0ea0 100644 --- a/activitystreams-derive/src/lib.rs +++ b/activitystreams-derive/src/lib.rs @@ -23,8 +23,8 @@ //! //! First, add `serde` and `activitystreams-derive` to your Cargo.toml //! ```toml -//! activitystreams-derive = "0.5.0-alpha.2" -//! # or activitystreams = "0.5.0-alpha.3" +//! activitystreams-derive = "0.5.0-alpha.3" +//! # or activitystreams = "0.5.0-alpha.4" //! serde = { version = "1.0", features = ["derive"] } //! ``` //! @@ -1060,12 +1060,12 @@ pub fn properties(tokens: TokenStream) -> TokenStream { /// /// The returned vec will be empty if no values match the requested /// type, but values are present. - pub fn #get_many_ident(&self) -> Option> { + pub fn #get_many_ident(&self) -> Option> { match self.#fname { #ty::Array(ref array) => Some(array.iter().filter_map(|i| match i { #term_ty::#v_ty(item) => Some(item), _ => None, - }).collect()), + })), _ => None, } } @@ -1130,12 +1130,12 @@ pub fn properties(tokens: TokenStream) -> TokenStream { /// This returns `None` if /// - There is no value present /// - There is only one value present - pub fn #get_many_ident(&self) -> Option> { + pub fn #get_many_ident(&self) -> Option> { match self.#fname { Some(#ty::Array(ref array)) => Some(array.iter().filter_map(|i| match i { #term_ty::#v_ty(item) => Some(item), _ => None, - }).collect()), + })), _ => None, } } diff --git a/examples/de.rs b/examples/de.rs index 1eebcda..74293b1 100644 --- a/examples/de.rs +++ b/examples/de.rs @@ -1,5 +1,5 @@ use activitystreams::{ - collection::apub::OrderedCollection, + collection::{apub::OrderedCollection, properties::CollectionProperties}, object::{streams::Page, ObjectBox}, }; use anyhow::Error; @@ -51,5 +51,14 @@ fn main() -> Result<(), Error> { let collection: OrderedCollection = serde_json::from_str(collection_json)?; println!("{:#?}", collection); + let cprops: &CollectionProperties = collection.as_ref(); + let v: Vec = cprops + .get_many_items_object_boxs() + .unwrap() + .map(|object_box| object_box.clone().to_concrete::()) + .collect::, std::io::Error>>()?; + + println!("{:#?}", v); + Ok(()) } diff --git a/src/lib.rs b/src/lib.rs index fc3f961..c453f2d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,7 +25,7 @@ //! //! First, add ActivityStreams to your dependencies //! ```toml -//! activitystreams = "0.5.0-alpha.3" +//! activitystreams = "0.5.0-alpha.4" //! ``` //! //! ### Types @@ -193,7 +193,7 @@ //! enabled. //! //! ```toml -//! activitystreams = { version = "0.5.0-alpha.3", default-features = "false", features = ["derive"] } +//! activitystreams = { version = "0.5.0-alpha.4", default-features = "false", features = ["derive"] } //! ``` //! //! | feature | what you get | diff --git a/src/object/mod.rs b/src/object/mod.rs index eb589ce..f5cbbda 100644 --- a/src/object/mod.rs +++ b/src/object/mod.rs @@ -53,6 +53,7 @@ pub struct AnyImage { rest: std::collections::HashMap, } +#[cfg(feature = "types")] impl AnyImage { pub fn from_concrete(t: T) -> Result where