diff --git a/Cargo.toml b/Cargo.toml index cf26826..e51ef59 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "activitystreams" description = "Activity Streams in Rust" -version = "0.5.0-alpha.11" +version = "0.5.0-alpha.12" 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"] [dependencies] -activitystreams-derive = { version = "0.5.0-alpha.4", path = "activitystreams-derive", optional = true} +activitystreams-derive = { version = "0.5.0-alpha.5", 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 d651a08..440f6fe 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.11" +activitystreams = "0.5.0-alpha.12" ``` ### 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.11", default-features = "false", features = ["derive"] } +activitystreams = { version = "0.5.0-alpha.12", default-features = "false", features = ["derive"] } ``` | feature | what you get | diff --git a/activitystreams-derive/Cargo.toml b/activitystreams-derive/Cargo.toml index 6f0f91d..b79ea73 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.4" +version = "0.5.0-alpha.5" 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 f5f92f4..1d8f46f 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.4" +activitystreams = "0.5.0-alpha.12" serde = { version = "1.0", features = ["derive"] } ``` diff --git a/activitystreams-derive/src/lib.rs b/activitystreams-derive/src/lib.rs index df619e8..f93c783 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.4" -//! # or activitystreams = "0.5.0-alpha.9" +//! activitystreams-derive = "0.5.0-alpha.5" +//! # or activitystreams = "0.5.0-alpha.12" //! serde = { version = "1.0", features = ["derive"] } //! ``` //! @@ -239,6 +239,29 @@ pub fn ref_derive(input: TokenStream) -> TokenStream { #box_name::from_concrete(s) } } + + impl std::convert::TryFrom> for #box_name + where + T: serde::de::DeserializeOwned + serde::ser::Serialize + std::fmt::Debug, + { + type Error = std::io::Error; + + fn try_from(s: Ext<#name, T>) -> Result { + #box_name::from_concrete(s) + } + } + + impl std::convert::TryFrom, U>> for #box_name + where + T: serde::de::DeserializeOwned + serde::ser::Serialize + std::fmt::Debug, + U: serde::de::DeserializeOwned + serde::ser::Serialize + std::fmt::Debug, + { + type Error = std::io::Error; + + fn try_from(s: Ext, U>) -> Result { + #box_name::from_concrete(s) + } + } }) } else { None diff --git a/src/lib.rs b/src/lib.rs index fcd0611..137fc31 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.11" +//! activitystreams = "0.5.0-alpha.12" //! ``` //! //! ### Types @@ -209,7 +209,7 @@ //! enabled. //! //! ```toml -//! activitystreams = { version = "0.5.0-alpha.11", default-features = "false", features = ["derive"] } +//! activitystreams = { version = "0.5.0-alpha.12", default-features = "false", features = ["derive"] } //! ``` //! //! | feature | what you get |