From 0797fb8742dda279119b757b24557bd856c8f3c9 Mon Sep 17 00:00:00 2001 From: asonix Date: Mon, 28 Oct 2019 16:04:11 -0500 Subject: [PATCH] Apply anyhow patch from romain@leroux.dev --- Cargo.toml | 10 +++++----- README.md | 12 +++++------- activitystreams-derive/Cargo.toml | 4 ++-- activitystreams-derive/README.md | 4 ++-- activitystreams-traits/Cargo.toml | 4 ++-- activitystreams-traits/src/error.rs | 8 ++++---- activitystreams-traits/src/lib.rs | 2 -- activitystreams-types/Cargo.toml | 8 ++++---- activitystreams-types/README.md | 2 +- activitystreams-types/src/lib.rs | 5 ++--- src/lib.rs | 10 ++++------ 11 files changed, 31 insertions(+), 38 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 874792b..79bd4fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "activitystreams" description = "Activity Streams in Rust" -version = "0.2.4" +version = "0.3.0" license = "GPL-3.0" authors = ["asonix "] repository = "https://git.asonix.dog/Aardwolf/activitystreams" @@ -9,15 +9,15 @@ readme = "README.md" keywords = ["activitystreams", "activitypub"] [dependencies] -activitystreams-traits = { version = "0.1", path = "activitystreams-traits" } -activitystreams-types = { version = "0.2.3", path = "activitystreams-types" } +activitystreams-traits = { version = "0.2", path = "activitystreams-traits" } +activitystreams-types = { version = "0.3.0", path = "activitystreams-types" } [dev-dependencies] -failure = "0.1" +anyhow = "1.0" serde = "1.0" serde_derive = "1.0" serde_json = "1.0" -activitystreams-derive = { version = "0.1", path = "activitystreams-derive" } +activitystreams-derive = { version = "0.2", path = "activitystreams-derive" } [workspace] members = [ diff --git a/README.md b/README.md index 81deb59..236fe7d 100644 --- a/README.md +++ b/README.md @@ -12,20 +12,19 @@ For basic use, add the following to your Cargo.toml ```toml # Cargo.toml -activitystreams = "0.2" +activitystreams = "0.3" ``` And then use it in your project ```rust extern crate activitystreams; -extern crate failure; +extern crate anyhow; extern crate serde; #[macro_use] extern crate serde_derive; extern crate serde_json; use activitystreams::{context, Object, Actor, object::Profile}; -use failure::Error; #[derive(Clone, Debug, Default, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] @@ -40,7 +39,7 @@ pub struct Persona { impl Object for Persona {} impl Actor for Persona {} -fn run() -> Result<(), Error> { +fn run() -> Result<(), anyhow::Error> { let mut profile = Profile::default(); profile.profile.set_describes_object(Persona { @@ -77,7 +76,7 @@ And then in your project extern crate activitystreams_derive; extern crate activitystreams_traits; extern crate activitystreams_types; -extern crate failure; +extern crate anyhow; extern crate serde; #[macro_use] extern crate serde_derive; @@ -85,7 +84,6 @@ extern crate serde_json; use activitystreams_traits::{Link, Object}; use activitystreams_types::{CustomLink, link::Mention}; -use failure::Error; /// Using the UnitString derive macro /// @@ -118,7 +116,7 @@ pub struct MyProperties { pub required_key: serde_json::Value, } -fn run() -> Result<(), Error> { +fn run() -> Result<(), anyhow::Error> { let mut props = MyProperties::default(); props.set_required_key_string("Hey".to_owned())?; diff --git a/activitystreams-derive/Cargo.toml b/activitystreams-derive/Cargo.toml index 3910035..cfc9ca0 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.1.1" +version = "0.2.0" license = "GPL-3.0" authors = ["asonix "] repository = "https://git.asonix.dog/Aardwolf/activitystreams" @@ -14,7 +14,7 @@ syn = "0.13" proc-macro2 = "0.3" [dev-dependencies] -activitystreams-traits = { version = "0.1", path = "../activitystreams-traits" } +activitystreams-traits = { version = "0.2", path = "../activitystreams-traits" } serde = "1.0" serde_derive = "1.0" serde_json = "1.0" diff --git a/activitystreams-derive/README.md b/activitystreams-derive/README.md index fe018ae..c6263ee 100644 --- a/activitystreams-derive/README.md +++ b/activitystreams-derive/README.md @@ -10,8 +10,8 @@ Add the required crates to your `Cargo.toml` ```toml # Cargo.toml -activitystreams-derive = "0.1" -activitystreams-traits = "0.1" +activitystreams-derive = "0.2" +activitystreams-traits = "0.2" serde = "1.0" serde_derive = "1.0" serde_json = "1.0" diff --git a/activitystreams-traits/Cargo.toml b/activitystreams-traits/Cargo.toml index 5ea8350..4292c52 100644 --- a/activitystreams-traits/Cargo.toml +++ b/activitystreams-traits/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "activitystreams-traits" description = "Traits for ActivityStreams objects" -version = "0.1.0" +version = "0.2.0" license = "GPL-3.0" authors = ["asonix "] repository = "https://git.asonix.dog/Aardwolf/activitystreams" @@ -9,9 +9,9 @@ readme = "README.md" keywords = ["activitystreams", "activitypub"] [dependencies] -failure = "0.1" serde = "1.0" serde_json = "1.0" +thiserror = "1.0" [dev-dependencies] serde_derive = "1.0" diff --git a/activitystreams-traits/src/error.rs b/activitystreams-traits/src/error.rs index c5f1666..d6a4e84 100644 --- a/activitystreams-traits/src/error.rs +++ b/activitystreams-traits/src/error.rs @@ -20,19 +20,19 @@ use std::result; /// The Error type -#[derive(Copy, Clone, Debug, Eq, Fail, PartialEq)] +#[derive(Copy, Clone, Debug, Eq, PartialEq, thiserror::Error)] pub enum Error { /// This error occurs when an Activity Streams type does not contain a requested value - #[fail(display = "Key not present")] + #[error("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")] + #[error("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")] + #[error("Failed to serialize data")] Serialize, } diff --git a/activitystreams-traits/src/lib.rs b/activitystreams-traits/src/lib.rs index 5fb6096..9e6745c 100644 --- a/activitystreams-traits/src/lib.rs +++ b/activitystreams-traits/src/lib.rs @@ -49,8 +49,6 @@ //! # fn main() {} //! ``` -#[macro_use] -extern crate failure; extern crate serde; extern crate serde_json; diff --git a/activitystreams-types/Cargo.toml b/activitystreams-types/Cargo.toml index 2c5a8b4..bb500c4 100644 --- a/activitystreams-types/Cargo.toml +++ b/activitystreams-types/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "activitystreams-types" description = "Base types from the Activity Streams spec" -version = "0.2.3" +version = "0.3.0" license = "GPL-3.0" authors = ["asonix "] repository = "https://git.asonix.dog/Aardwolf/activitystreams" @@ -9,8 +9,8 @@ readme = "README.md" keywords = ["activitystreams", "activitypub"] [dependencies] -activitystreams-derive = { version = "0.1", path = "../activitystreams-derive" } -activitystreams-traits = { version = "0.1", path = "../activitystreams-traits" } +activitystreams-derive = { version = "0.2", path = "../activitystreams-derive" } +activitystreams-traits = { version = "0.2", path = "../activitystreams-traits" } chrono = { version = "0.4", features = ["serde"] } mime = "0.3" serde = "1.0" @@ -18,4 +18,4 @@ serde_derive = "1.0" serde_json = "1.0" [dev-dependencies] -failure = "0.1" +anyhow = "1.0" diff --git a/activitystreams-types/README.md b/activitystreams-types/README.md index d145891..378a335 100644 --- a/activitystreams-types/README.md +++ b/activitystreams-types/README.md @@ -10,7 +10,7 @@ First, add the crate to your cargo.toml ```toml # Cargo.toml -activitystreams-types = "0.2" +activitystreams-types = "0.3" ``` Then use it in your project! diff --git a/activitystreams-types/src/lib.rs b/activitystreams-types/src/lib.rs index 21e8b2e..65bb952 100644 --- a/activitystreams-types/src/lib.rs +++ b/activitystreams-types/src/lib.rs @@ -24,13 +24,12 @@ //! ## Example Usage //! ```rust //! extern crate activitystreams_types; -//! extern crate failure; +//! extern crate anyhow; //! extern crate serde_json; //! //! use activitystreams_types::{context, link::Mention}; -//! use failure::Error; //! -//! fn run() -> Result<(), Error> { +//! fn run() -> Result<(), anyhow::Error> { //! /// A Mention is the only predefined Link type in the Activity Streams spec //! let mut mention = Mention::default(); //! mention.link_props.set_context_object(context())?; diff --git a/src/lib.rs b/src/lib.rs index bfe5705..f1ef18f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -27,14 +27,13 @@ //! //! ```rust //! extern crate activitystreams; -//! extern crate failure; +//! extern crate anyhow; //! extern crate serde; //! #[macro_use] //! extern crate serde_derive; //! extern crate serde_json; //! //! use activitystreams::{context, Object, Actor, object::Profile}; -//! use failure::Error; //! //! #[derive(Clone, Debug, Default, Deserialize, Serialize)] //! #[serde(rename_all = "camelCase")] @@ -49,7 +48,7 @@ //! impl Object for Persona {} //! impl Actor for Persona {} //! -//! fn run() -> Result<(), Error> { +//! fn run() -> Result<(), anyhow::Error> { //! let mut profile = Profile::default(); //! //! profile.profile.set_describes_object(Persona { @@ -79,7 +78,7 @@ //! extern crate activitystreams_derive; //! extern crate activitystreams_traits; //! extern crate activitystreams_types; -//! extern crate failure; +//! extern crate anyhow; //! extern crate serde; //! #[macro_use] //! extern crate serde_derive; @@ -87,7 +86,6 @@ //! //! use activitystreams_traits::{Link, Object}; //! use activitystreams_types::{CustomLink, link::Mention}; -//! use failure::Error; //! //! /// Using the UnitString derive macro //! /// @@ -120,7 +118,7 @@ //! pub required_key: serde_json::Value, //! } //! -//! fn run() -> Result<(), Error> { +//! fn run() -> Result<(), anyhow::Error> { //! let mut props = MyProperties::default(); //! //! props.set_required_key_string("Hey".to_owned())?;