From 0979abb6949611eb60c205d7021c7eb14abc422b Mon Sep 17 00:00:00 2001 From: asonix Date: Wed, 3 Jun 2020 15:35:45 -0500 Subject: [PATCH] Introduce 'uri' macro --- examples/basic.rs | 8 +- src/activity.rs | 296 ++++++++++++--------------------- src/actor.rs | 74 ++++----- src/base.rs | 127 +++++++------- src/collection.rs | 254 +++++++--------------------- src/lib.rs | 64 ++++--- src/link.rs | 38 +++-- src/object.rs | 412 +++++++++++++++++++++++----------------------- 8 files changed, 541 insertions(+), 732 deletions(-) diff --git a/examples/basic.rs b/examples/basic.rs index 5929658..84ad634 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -2,7 +2,7 @@ use activitystreams_new::{ context, object::{ApObject, Video}, prelude::*, - primitives::XsdAnyUri, + uri, }; fn main() -> Result<(), anyhow::Error> { @@ -10,12 +10,12 @@ fn main() -> Result<(), anyhow::Error> { video .set_context(context()) - .set_id("https://example.com/@example/lions".parse()?) + .set_id(uri!("https://example.com/@example/lions")) .set_media_type("video/webm".parse()?) - .set_url("https://example.com/@example/lions/video.webm".parse::()?) + .set_url(uri!("https://example.com/@example/lions/video.webm")) .set_summary("A cool video".to_owned()) .set_duration("PT4M20S".parse()?) - .set_shares("https://example.com/@example/lions/video.webm#shares".parse()?); + .set_shares(uri!("https://example.com/@example/lions/video.webm#shares")); println!("Video, {:#?}", video); diff --git a/src/activity.rs b/src/activity.rs index 7da1c0e..e93a46f 100644 --- a/src/activity.rs +++ b/src/activity.rs @@ -6,18 +6,18 @@ //! activity::Create, //! context, //! prelude::*, -//! primitives::XsdAnyUri, +//! uri, //! }; //! //! let mut create = Create::new( -//! "https://example.com/actors/abcd".parse::()?, -//! "https://example.com/notes/1234".parse::()?, +//! uri!("https://example.com/actors/abcd"), +//! uri!("https://example.com/notes/1234"), //! ); //! //! create -//! .set_result("https://example.com/".parse::()?) -//! .set_instrument("https://example.com/".parse::()?) -//! .set_id("https://example.com/activities/abcd".parse()?) +//! .set_result(uri!("https://example.com/")) +//! .set_instrument(uri!("https://example.com/")) +//! .set_id(uri!("https://example.com/activities/abcd")) //! .set_context(context()); //! # Ok(()) //! # } @@ -164,10 +164,10 @@ pub trait ActivityExt: AsActivity { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{activity::Question, primitives::XsdAnyUri}; + /// # use activitystreams_new::{activity::Question, uri}; /// # let mut question = Question::new(); /// - /// question.set_result("https://example.com".parse::()?); + /// question.set_result(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -186,12 +186,12 @@ pub trait ActivityExt: AsActivity { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{activity::Question, primitives::XsdAnyUri}; + /// # use activitystreams_new::{activity::Question, uri}; /// # let mut question = Question::new(); /// /// question.set_many_results(vec![ - /// "https://example.com/one".parse::()?, - /// "https://example.com/two".parse()?, + /// uri!("https://example.com/one"), + /// uri!("https://example.com/two"), /// ]); /// # Ok(()) /// # } @@ -212,13 +212,13 @@ pub trait ActivityExt: AsActivity { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{activity::Question, primitives::XsdAnyUri}; + /// use activitystreams_new::{prelude::*, uri}; + /// # use activitystreams_new::{activity::Question}; /// # let mut question = Question::new(); /// /// question - /// .add_result("https://example.com/one".parse::()?) - /// .add_result("https://example.com/two".parse::()?); + /// .add_result(uri!("https://example.com/one")) + /// .add_result(uri!("https://example.com/two")); /// # Ok(()) /// # } /// ``` @@ -257,9 +257,9 @@ pub trait ActivityExt: AsActivity { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{activity::Question, primitives::XsdAnyUri}; + /// # use activitystreams_new::{activity::Question, uri}; /// # let mut question = Question::new(); - /// # question.set_result("https://example.com".parse::()?); + /// # question.set_result(uri!("https://example.com")); /// # /// use activitystreams_new::prelude::*; /// @@ -300,10 +300,10 @@ pub trait ActivityExt: AsActivity { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{activity::Question, primitives::XsdAnyUri}; + /// # use activitystreams_new::{activity::Question, uri}; /// # let mut question = Question::new(); /// - /// question.set_instrument("https://example.com".parse::()?); + /// question.set_instrument(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -322,12 +322,12 @@ pub trait ActivityExt: AsActivity { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{activity::Question, primitives::XsdAnyUri}; + /// # use activitystreams_new::{activity::Question, uri}; /// # let mut question = Question::new(); /// /// question.set_many_instruments(vec![ - /// "https://example.com/one".parse::()?, - /// "https://example.com/two".parse()?, + /// uri!("https://example.com/one"), + /// uri!("https://example.com/two"), /// ]); /// # Ok(()) /// # } @@ -349,12 +349,12 @@ pub trait ActivityExt: AsActivity { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{activity::Question, primitives::XsdAnyUri}; + /// # use activitystreams_new::{activity::Question, uri}; /// # let mut question = Question::new(); /// /// question - /// .add_instrument("https://example.com/one".parse::()?) - /// .add_instrument("https://example.com/two".parse::()?); + /// .add_instrument(uri!("https://example.com/one")) + /// .add_instrument(uri!("https://example.com/two")); /// # Ok(()) /// # } /// ``` @@ -393,9 +393,9 @@ pub trait ActivityExt: AsActivity { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{activity::Question, primitives::XsdAnyUri}; + /// # use activitystreams_new::{activity::Question, uri}; /// # let mut question = Question::new(); - /// # question.set_instrument("https://example.com".parse::()?); + /// # question.set_instrument(uri!("https://example.com")); /// # /// use activitystreams_new::prelude::*; /// @@ -435,17 +435,13 @@ pub trait ActorAndObjectRefExt: ActorAndObjectRef { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{ - /// # context, - /// # activity::Create, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, activity::Create, uri}; /// # let mut create = Create::new(context(), context()); /// use activitystreams_new::prelude::*; /// - /// create.set_actor("https://example.com".parse::()?); + /// create.set_actor(uri!("https://example.com")); /// - /// assert!(create.actor_is(&"https://example.com".parse()?)); + /// assert!(create.actor_is(&uri!("https://example.com"))); /// # Ok(()) /// # } /// ``` @@ -460,14 +456,10 @@ pub trait ActorAndObjectRefExt: ActorAndObjectRef { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{ - /// # context, - /// # activity::Create, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, activity::Create, uri}; /// # let mut create = Create::new(context(), context()); /// - /// create.set_actor("https://example.com".parse::()?); + /// create.set_actor(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -486,16 +478,12 @@ pub trait ActorAndObjectRefExt: ActorAndObjectRef { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{ - /// # context, - /// # activity::Create, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, activity::Create, uri}; /// # let mut create = Create::new(context(), context()); /// /// create.set_many_actors(vec![ - /// "https://example.com/one".parse::()?, - /// "https://example.com/two".parse()?, + /// uri!("https://example.com/one"), + /// uri!("https://example.com/two"), /// ]); /// # Ok(()) /// # } @@ -517,16 +505,12 @@ pub trait ActorAndObjectRefExt: ActorAndObjectRef { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{ - /// # context, - /// # activity::Create, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, activity::Create, uri}; /// # let mut create = Create::new(context(), context()); /// /// create - /// .add_actor("https://example.com/one".parse::()?) - /// .add_actor("https://example.com/two".parse::()?); + /// .add_actor(uri!("https://example.com/one")) + /// .add_actor(uri!("https://example.com/two")); /// # Ok(()) /// # } /// ``` @@ -557,17 +541,13 @@ pub trait ActorAndObjectRefExt: ActorAndObjectRef { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{ - /// # context, - /// # activity::Create, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, activity::Create, uri}; /// # let mut create = Create::new(context(), context()); /// use activitystreams_new::prelude::*; /// - /// create.set_object("https://example.com".parse::()?); + /// create.set_object(uri!("https://example.com")); /// - /// assert!(create.object_is(&"https://example.com".parse()?)); + /// assert!(create.object_is(&uri!("https://example.com"))); /// # Ok(()) /// # } /// ``` @@ -582,14 +562,10 @@ pub trait ActorAndObjectRefExt: ActorAndObjectRef { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{ - /// # context, - /// # activity::Create, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, activity::Create, uri}; /// # let mut create = Create::new(context(), context()); /// - /// create.set_object("https://example.com".parse::()?); + /// create.set_object(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -608,16 +584,12 @@ pub trait ActorAndObjectRefExt: ActorAndObjectRef { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{ - /// # context, - /// # activity::Create, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, activity::Create, uri}; /// # let mut create = Create::new(context(), context()); /// /// create.set_many_objects(vec![ - /// "https://example.com/one".parse::()?, - /// "https://example.com/two".parse()?, + /// uri!("https://example.com/one"), + /// uri!("https://example.com/two"), /// ]); /// # Ok(()) /// # } @@ -639,16 +611,12 @@ pub trait ActorAndObjectRefExt: ActorAndObjectRef { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{ - /// # context, - /// # activity::Create, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, activity::Create, uri}; /// # let mut create = Create::new(context(), context()); /// /// create - /// .add_object("https://example.com/one".parse::()?) - /// .add_object("https://example.com/two".parse::()?); + /// .add_object(uri!("https://example.com/one")) + /// .add_object(uri!("https://example.com/two")); /// # Ok(()) /// # } /// ``` @@ -687,14 +655,10 @@ pub trait TargetRefExt: TargetRef { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{ - /// # context, - /// # activity::Invite, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, activity::Invite, uri}; /// # let mut invite = Invite::new(context(), context(), context()); /// - /// invite.set_target("https://example.com".parse::()?); + /// invite.set_target(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -713,16 +677,12 @@ pub trait TargetRefExt: TargetRef { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{ - /// # context, - /// # activity::Invite, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, activity::Invite, uri}; /// # let mut invite = Invite::new(context(), context(), context()); /// /// invite.set_many_targets(vec![ - /// "https://example.com/one".parse::()?, - /// "https://example.com/two".parse()?, + /// uri!("https://example.com/one"), + /// uri!("https://example.com/two"), /// ]); /// # Ok(()) /// # } @@ -744,16 +704,12 @@ pub trait TargetRefExt: TargetRef { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{ - /// # context, - /// # activity::Invite, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, activity::Invite, uri}; /// # let mut invite = Invite::new(context(), context(), context()); /// /// invite - /// .add_target("https://example.com/one".parse::()?) - /// .add_target("https://example.com/two".parse::()?); + /// .add_target(uri!("https://example.com/one")) + /// .add_target(uri!("https://example.com/two")); /// # Ok(()) /// # } /// ``` @@ -792,14 +748,10 @@ pub trait OriginRefExt: OriginRef { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{ - /// # context, - /// # activity::Arrive, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, activity::Arrive, uri}; /// # let mut arrive = Arrive::new(context(), context()); /// - /// arrive.set_origin("https://example.com".parse::()?); + /// arrive.set_origin(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -818,16 +770,12 @@ pub trait OriginRefExt: OriginRef { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{ - /// # context, - /// # activity::Arrive, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, activity::Arrive, uri}; /// # let mut arrive = Arrive::new(context(), context()); /// /// arrive.set_many_origins(vec![ - /// "https://example.com/one".parse::()?, - /// "https://example.com/two".parse()?, + /// uri!("https://example.com/one"), + /// uri!("https://example.com/two"), /// ]); /// # Ok(()) /// # } @@ -849,16 +797,12 @@ pub trait OriginRefExt: OriginRef { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{ - /// # context, - /// # activity::Arrive, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, activity::Arrive, uri}; /// # let mut arrive = Arrive::new(context(), context()); /// /// arrive - /// .add_origin("https://example.com/one".parse::()?) - /// .add_origin("https://example.com/two".parse::()?); + /// .add_origin(uri!("https://example.com/one")) + /// .add_origin(uri!("https://example.com/two")); /// # Ok(()) /// # } /// ``` @@ -899,14 +843,10 @@ pub trait OptTargetRefExt: OptTargetRef { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{ - /// # context, - /// # activity::Announce, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, activity::Announce, uri}; /// # let mut announce = Announce::new(context(), context()); /// - /// announce.set_target("https://example.com".parse::()?); + /// announce.set_target(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -925,16 +865,12 @@ pub trait OptTargetRefExt: OptTargetRef { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{ - /// # context, - /// # activity::Announce, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, activity::Announce, uri}; /// # let mut announce = Announce::new(context(), context()); /// /// announce.set_many_targets(vec![ - /// "https://example.com/one".parse::()?, - /// "https://example.com/two".parse()?, + /// uri!("https://example.com/one"), + /// uri!("https://example.com/two"), /// ]); /// # Ok(()) /// # } @@ -956,16 +892,12 @@ pub trait OptTargetRefExt: OptTargetRef { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{ - /// # context, - /// # activity::Announce, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, activity::Announce, uri}; /// # let mut announce = Announce::new(context(), context()); /// /// announce - /// .add_target("https://example.com/one".parse::()?) - /// .add_target("https://example.com/two".parse::()?); + /// .add_target(uri!("https://example.com/one")) + /// .add_target(uri!("https://example.com/two")); /// # Ok(()) /// # } /// ``` @@ -992,7 +924,6 @@ pub trait OptTargetRefExt: OptTargetRef { /// # use activitystreams_new::{ /// # context, /// # activity::Announce, - /// # primitives::XsdAnyUri /// # }; /// # let mut announce = Announce::new(context(), context()); /// @@ -1014,7 +945,6 @@ pub trait OptTargetRefExt: OptTargetRef { /// # use activitystreams_new::{ /// # context, /// # activity::Announce, - /// # primitives::XsdAnyUri /// # }; /// # let mut announce = Announce::new(context(), context()); /// # announce.set_target(context()); @@ -1059,14 +989,10 @@ pub trait OptOriginRefExt: OptOriginRef { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{ - /// # context, - /// # activity::Delete, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, activity::Delete, uri}; /// # let mut delete = Delete::new(context(), context()); /// - /// delete.set_origin("https://example.com".parse::()?); + /// delete.set_origin(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -1085,16 +1011,12 @@ pub trait OptOriginRefExt: OptOriginRef { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{ - /// # context, - /// # activity::Delete, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, activity::Delete, uri}; /// # let mut delete = Delete::new(context(), context()); /// /// delete.set_many_origins(vec![ - /// "https://example.com/one".parse::()?, - /// "https://example.com/two".parse()?, + /// uri!("https://example.com/one"), + /// uri!("https://example.com/two"), /// ]); /// # Ok(()) /// # } @@ -1116,16 +1038,12 @@ pub trait OptOriginRefExt: OptOriginRef { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{ - /// # context, - /// # activity::Delete, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, activity::Delete, uri}; /// # let mut delete = Delete::new(context(), context()); /// /// delete - /// .add_origin("https://example.com/one".parse::()?) - /// .add_origin("https://example.com/two".parse::()?); + /// .add_origin(uri!("https://example.com/one")) + /// .add_origin(uri!("https://example.com/two")); /// # Ok(()) /// # } /// ``` @@ -1149,11 +1067,7 @@ pub trait OptOriginRefExt: OptOriginRef { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{ - /// # context, - /// # activity::Delete, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, activity::Delete}; /// # let mut delete = Delete::new(context(), context()); /// /// if let Some(origin) = delete.take_origin() { @@ -1171,11 +1085,7 @@ pub trait OptOriginRefExt: OptOriginRef { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{ - /// # context, - /// # activity::Delete, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, activity::Delete}; /// # let mut delete = Delete::new(context(), context()); /// # delete.set_origin(context()); /// @@ -1221,10 +1131,10 @@ pub trait QuestionExt: AsQuestion { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{activity::Question, primitives::XsdAnyUri}; + /// # use activitystreams_new::{activity::Question, uri}; /// # let mut question = Question::new(); /// - /// question.set_one_of("https://example.com".parse::()?); + /// question.set_one_of(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -1243,12 +1153,12 @@ pub trait QuestionExt: AsQuestion { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{activity::Question, primitives::XsdAnyUri}; + /// # use activitystreams_new::{activity::Question, uri}; /// # let mut question = Question::new(); /// /// question.set_many_one_ofs(vec![ - /// "https://example.com/one".parse::()?, - /// "https://example.com/two".parse()?, + /// uri!("https://example.com/one"), + /// uri!("https://example.com/two"), /// ]); /// # Ok(()) /// # } @@ -1270,12 +1180,12 @@ pub trait QuestionExt: AsQuestion { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{activity::Question, primitives::XsdAnyUri}; + /// # use activitystreams_new::{activity::Question, uri}; /// # let mut question = Question::new(); /// /// question - /// .add_one_of("https://example.com/one".parse::()?) - /// .add_one_of("https://example.com/two".parse::()?); + /// .add_one_of(uri!("https://example.com/one")) + /// .add_one_of(uri!("https://example.com/two")); /// # Ok(()) /// # } /// ``` @@ -1314,9 +1224,9 @@ pub trait QuestionExt: AsQuestion { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{activity::Question, primitives::XsdAnyUri}; + /// # use activitystreams_new::{activity::Question, uri}; /// # let mut question = Question::new(); - /// # question.set_one_of("https://example.com".parse::()?); + /// # question.set_one_of(uri!("https://example.com")); /// # /// use activitystreams_new::prelude::*; /// @@ -1354,10 +1264,10 @@ pub trait QuestionExt: AsQuestion { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{activity::Question, primitives::XsdAnyUri}; + /// # use activitystreams_new::{activity::Question, uri}; /// # let mut question = Question::new(); /// - /// question.set_any_of("https://example.com".parse::()?); + /// question.set_any_of(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -1376,12 +1286,12 @@ pub trait QuestionExt: AsQuestion { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{activity::Question, primitives::XsdAnyUri}; + /// # use activitystreams_new::{activity::Question, uri}; /// # let mut question = Question::new(); /// /// question.set_many_any_ofs(vec![ - /// "https://example.com/one".parse::()?, - /// "https://example.com/two".parse()?, + /// uri!("https://example.com/one"), + /// uri!("https://example.com/two"), /// ]); /// # Ok(()) /// # } @@ -1403,12 +1313,12 @@ pub trait QuestionExt: AsQuestion { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{activity::Question, primitives::XsdAnyUri}; + /// # use activitystreams_new::{activity::Question, uri}; /// # let mut question = Question::new(); /// /// question - /// .add_any_of("https://example.com/one".parse::()?) - /// .add_any_of("https://example.com/two".parse::()?); + /// .add_any_of(uri!("https://example.com/one")) + /// .add_any_of(uri!("https://example.com/two")); /// # Ok(()) /// # } /// ``` @@ -1447,9 +1357,9 @@ pub trait QuestionExt: AsQuestion { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{activity::Question, primitives::XsdAnyUri}; + /// # use activitystreams_new::{activity::Question, uri}; /// # let mut question = Question::new(); - /// # question.set_any_of("https://example.com".parse::()?); + /// # question.set_any_of(uri!("https://example.com")); /// # /// use activitystreams_new::prelude::*; /// diff --git a/src/actor.rs b/src/actor.rs index 474de14..9318420 100644 --- a/src/actor.rs +++ b/src/actor.rs @@ -5,18 +5,18 @@ //! use activitystreams_new::{ //! actor::{ApActor, Person}, //! prelude::*, -//! primitives::XsdAnyUri, +//! uri, //! }; //! //! let mut person = ApActor::new( -//! "https://example.com/actor/inbox".parse()?, +//! uri!("https://example.com/actor/inbox"), //! Person::new(), //! ); //! //! person -//! .set_outbox("https://example.com/actor/outbox".parse()?) -//! .set_following("https://example.com/actor/following".parse()?) -//! .set_followers("https://example.com/actor/followers".parse()?); +//! .set_outbox(uri!("https://example.com/actor/outbox")) +//! .set_following(uri!("https://example.com/actor/following")) +//! .set_followers(uri!("https://example.com/actor/followers")); //! # //! # Ok(()) //! # } @@ -78,11 +78,11 @@ pub trait ApActorExt: AsApActor { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{actor::{ApActor, Person}, context}; + /// # use activitystreams_new::{actor::{ApActor, Person}, context, uri}; /// # let mut person = ApActor::new(context(), Person::new()); /// use activitystreams_new::prelude::*; /// - /// person.set_inbox("https://example.com/inbox".parse()?); + /// person.set_inbox(uri!("https://example.com/inbox")); /// # Ok(()) /// # } /// ``` @@ -111,11 +111,11 @@ pub trait ApActorExt: AsApActor { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{actor::{ApActor, Person}, context}; + /// # use activitystreams_new::{actor::{ApActor, Person}, context, uri}; /// # let mut person = ApActor::new(context(), Person::new()); /// use activitystreams_new::prelude::*; /// - /// person.set_outbox("https://example.com/outbox".parse()?); + /// person.set_outbox(uri!("https://example.com/outbox")); /// # Ok(()) /// # } /// ``` @@ -143,9 +143,9 @@ pub trait ApActorExt: AsApActor { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{actor::{ApActor, Person}, context}; + /// # use activitystreams_new::{actor::{ApActor, Person}, context, uri}; /// # let mut person = ApActor::new(context(), Person::new()); - /// # person.set_outbox("https://example.com/outbox".parse()?); + /// # person.set_outbox(uri!("https://example.com/outbox")); /// use activitystreams_new::prelude::*; /// /// assert!(person.outbox().is_some()); @@ -181,11 +181,11 @@ pub trait ApActorExt: AsApActor { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{actor::{ApActor, Person}, context}; + /// # use activitystreams_new::{actor::{ApActor, Person}, context, uri}; /// # let mut person = ApActor::new(context(), Person::new()); /// use activitystreams_new::prelude::*; /// - /// person.set_following("https://example.com/following".parse()?); + /// person.set_following(uri!("https://example.com/following")); /// # Ok(()) /// # } /// ``` @@ -213,9 +213,9 @@ pub trait ApActorExt: AsApActor { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{actor::{ApActor, Person}, context}; + /// # use activitystreams_new::{actor::{ApActor, Person}, context, uri}; /// # let mut person = ApActor::new(context(), Person::new()); - /// # person.set_following("https://example.com/following".parse()?); + /// # person.set_following(uri!("https://example.com/following")); /// use activitystreams_new::prelude::*; /// /// assert!(person.following().is_some()); @@ -251,11 +251,11 @@ pub trait ApActorExt: AsApActor { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{actor::{ApActor, Person}, context}; + /// # use activitystreams_new::{actor::{ApActor, Person}, context, uri}; /// # let mut person = ApActor::new(context(), Person::new()); /// use activitystreams_new::prelude::*; /// - /// person.set_followers("https://example.com/followers".parse()?); + /// person.set_followers(uri!("https://example.com/followers")); /// # Ok(()) /// # } /// ``` @@ -283,9 +283,9 @@ pub trait ApActorExt: AsApActor { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{actor::{ApActor, Person}, context}; + /// # use activitystreams_new::{actor::{ApActor, Person}, context, uri}; /// # let mut person = ApActor::new(context(), Person::new()); - /// # person.set_followers("https://example.com/followers".parse()?); + /// # person.set_followers(uri!("https://example.com/followers")); /// use activitystreams_new::prelude::*; /// /// assert!(person.followers().is_some()); @@ -321,11 +321,11 @@ pub trait ApActorExt: AsApActor { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{actor::{ApActor, Person}, context}; + /// # use activitystreams_new::{actor::{ApActor, Person}, context, uri}; /// # let mut person = ApActor::new(context(), Person::new()); /// use activitystreams_new::prelude::*; /// - /// person.set_streams("https://example.com/liked".parse()?); + /// person.set_streams(uri!("https://example.com/liked")); /// # Ok(()) /// # } /// ``` @@ -353,9 +353,9 @@ pub trait ApActorExt: AsApActor { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{actor::{ApActor, Person}, context}; + /// # use activitystreams_new::{actor::{ApActor, Person}, context, uri}; /// # let mut person = ApActor::new(context(), Person::new()); - /// # person.set_liked("https://example.com/liked".parse()?); + /// # person.set_liked(uri!("https://example.com/liked")); /// use activitystreams_new::prelude::*; /// /// assert!(person.liked().is_some()); @@ -391,11 +391,11 @@ pub trait ApActorExt: AsApActor { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{actor::{ApActor, Person}, context}; + /// # use activitystreams_new::{actor::{ApActor, Person}, context, uri}; /// # let mut person = ApActor::new(context(), Person::new()); /// use activitystreams_new::prelude::*; /// - /// person.set_streams("https://example.com/streams".parse()?); + /// person.set_streams(uri!("https://example.com/streams")); /// # Ok(()) /// # } /// ``` @@ -408,13 +408,13 @@ pub trait ApActorExt: AsApActor { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{actor::{ApActor, Person}, context}; + /// # use activitystreams_new::{actor::{ApActor, Person}, context, uri}; /// # let mut person = ApActor::new(context(), Person::new()); /// use activitystreams_new::prelude::*; /// /// person.set_many_streams(vec![ - /// "https://example.com/streams1".parse()?, - /// "https://example.com/streams2".parse()? + /// uri!("https://example.com/streams1"), + /// uri!("https://example.com/streams2"), /// ]); /// # Ok(()) /// # } @@ -432,13 +432,13 @@ pub trait ApActorExt: AsApActor { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{actor::{ApActor, Person}, context}; + /// # use activitystreams_new::{actor::{ApActor, Person}, context, uri}; /// # let mut person = ApActor::new(context(), Person::new()); /// use activitystreams_new::prelude::*; /// /// person - /// .add_streams("https://example.com/streams1".parse()?) - /// .add_streams("https://example.com/streams2".parse()?); + /// .add_streams(uri!("https://example.com/streams1")) + /// .add_streams(uri!("https://example.com/streams2")); /// # Ok(()) /// # } /// ``` @@ -473,9 +473,9 @@ pub trait ApActorExt: AsApActor { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{actor::{ApActor, Person}, context}; + /// # use activitystreams_new::{actor::{ApActor, Person}, context, uri}; /// # let mut person = ApActor::new(context(), Person::new()); - /// # person.set_streams("https://example.com/streams".parse()?); + /// # person.set_streams(uri!("https://example.com/streams")); /// use activitystreams_new::prelude::*; /// /// assert!(person.streams().is_some()); @@ -584,12 +584,12 @@ pub trait ApActorExt: AsApActor { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{actor::{ApActor, Endpoints, Person}, context}; + /// # use activitystreams_new::{actor::{ApActor, Endpoints, Person}, context, uri}; /// # let mut person = ApActor::new(context(), Person::new()); /// use activitystreams_new::prelude::*; /// /// person.set_endpoints(Endpoints { - /// shared_inbox: Some("https://example.com/inbox".parse()?), + /// shared_inbox: Some(uri!("https://example.com/inbox")), /// ..Default::default() /// }); /// # Ok(()) @@ -865,10 +865,10 @@ impl ApActor { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// use activitystreams_new::actor::{ApActor, Person}; + /// use activitystreams_new::{actor::{ApActor, Person}, uri}; /// /// let actor = ApActor::new( - /// "https://example.com/inbox".parse()?, + /// uri!("https://example.com/inbox"), /// Person::new(), /// ); /// # Ok(()) diff --git a/src/base.rs b/src/base.rs index c373431..4ba623d 100644 --- a/src/base.rs +++ b/src/base.rs @@ -8,11 +8,12 @@ //! object::Video, //! prelude::*, //! security, +//! uri, //! }; //! let mut video = Video::new(); //! //! video -//! .set_id("https://example.com".parse()?) +//! .set_id(uri!("https://example.com")) //! .set_context(context()) //! .add_context(security()) //! .set_name("Hello"); @@ -266,11 +267,11 @@ pub trait BaseExt: AsBase { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// use activitystreams_new::{object::Video, prelude::*}; + /// use activitystreams_new::{object::Video, prelude::*, uri}; /// /// let video: Video = serde_json::from_str(r#"{"type":"Video","id":"https://example.com"}"#)?; /// - /// assert!(video.is_id(&"https://example.com".parse()?)); + /// assert!(video.is_id(&uri!("https://example.com"))); /// # Ok(()) /// # } /// ``` @@ -287,9 +288,9 @@ pub trait BaseExt: AsBase { /// # use activitystreams_new::object::Video; /// # let mut video = Video::new(); /// # - /// use activitystreams_new::prelude::*; + /// use activitystreams_new::{prelude::*, uri}; /// - /// video.set_id("https://example.com".parse()?); + /// video.set_id(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -648,10 +649,10 @@ pub trait BaseExt: AsBase { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// - /// video.set_preview("https://example.com".parse::()?); + /// video.set_preview(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -670,12 +671,12 @@ pub trait BaseExt: AsBase { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// /// video.set_many_previews(vec![ - /// "https://example.com/one".parse::()?, - /// "https://example.com/two".parse()?, + /// uri!("https://example.com/one"), + /// uri!("https://example.com/two"), /// ]); /// # Ok(()) /// # } @@ -697,12 +698,12 @@ pub trait BaseExt: AsBase { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// /// video - /// .add_preview("https://example.com/one".parse::()?) - /// .add_preview("https://example.com/two".parse::()?); + /// .add_preview(uri!("https://example.com/one")) + /// .add_preview(uri!("https://example.com/two")); /// # Ok(()) /// # } /// ``` @@ -741,9 +742,9 @@ pub trait BaseExt: AsBase { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); - /// # video.set_preview("https://example.com".parse::()?); + /// # video.set_preview(uri!("https://example.com")); /// # /// use activitystreams_new::prelude::*; /// @@ -1040,9 +1041,9 @@ impl AnyBase { /// Check if this object is an XsdAnyUri /// /// ```rust - /// # use activitystreams_new::base::AnyBase; + /// # use activitystreams_new::{base::AnyBase, uri}; /// # fn main() -> Result<(), anyhow::Error> { - /// let any_base = AnyBase::from_xsd_any_uri("https://example.com".parse()?); + /// let any_base = AnyBase::from_xsd_any_uri(uri!("https://example.com")); /// assert!(any_base.is_xsd_any_uri()); /// # Ok(()) /// # } @@ -1092,11 +1093,9 @@ impl AnyBase { /// #### Get the ID from the nested video /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{ - /// # object::Video, base::AnyBase, prelude::*, primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{object::Video, base::AnyBase, prelude::*, uri}; /// # let mut video = Video::new(); - /// let id = "https://example.com".parse::()?; + /// let id = uri!("https://example.com"); /// /// video.set_id(id.clone()); /// @@ -1109,10 +1108,8 @@ impl AnyBase { /// #### Get the ID from the AnyBase /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{ - /// # base::AnyBase, prelude::*, primitives::XsdAnyUri - /// # }; - /// let id = "https://example.com".parse::()?; + /// # use activitystreams_new::{base::AnyBase, prelude::*, uri}; + /// let id = uri!("https://example.com"); /// /// let any_base = AnyBase::from_xsd_any_uri(id.clone()); /// assert!(any_base.id().unwrap() == &id); @@ -1129,15 +1126,15 @@ impl AnyBase { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// # use activitystreams_new::{ - /// # object::{kind::VideoType, Video}, base::AnyBase, prelude::*, + /// # object::{kind::VideoType, Video}, base::AnyBase, prelude::*, uri /// # }; /// # let mut video = Video::new(); /// # - /// video.set_id("https://example.com".parse()?); + /// video.set_id(uri!("https://example.com")); /// /// let any_base = AnyBase::from_extended(video)?; /// - /// assert!(any_base.is_id(&"https://example.com".parse()?)); + /// assert!(any_base.is_id(&uri!("https://example.com"))); /// # Ok(()) /// # } /// ``` @@ -1223,9 +1220,9 @@ impl AnyBase { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::base::AnyBase; + /// # use activitystreams_new::{base::AnyBase, uri}; /// # - /// let any_base = AnyBase::from_xsd_any_uri("https://example.com".parse()?); + /// let any_base = AnyBase::from_xsd_any_uri(uri!("https://example.com")); /// /// assert!(any_base.as_xsd_any_uri().is_some()); /// # @@ -1271,9 +1268,9 @@ impl AnyBase { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::base::AnyBase; + /// # use activitystreams_new::{base::AnyBase, uri}; /// # - /// let any_base = AnyBase::from_xsd_any_uri("https://example.com".parse()?); + /// let any_base = AnyBase::from_xsd_any_uri(uri!("https://example.com")); /// /// assert!(any_base.take_xsd_any_uri().is_some()); /// # @@ -1319,11 +1316,11 @@ impl AnyBase { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::base::AnyBase; + /// # use activitystreams_new::{base::AnyBase, uri}; /// # /// let mut any_base = AnyBase::from_xsd_string("hi".into()); /// - /// any_base.set_xsd_any_uri("https://example.com".parse()?); + /// any_base.set_xsd_any_uri(uri!("https://example.com")); /// /// assert!(any_base.take_xsd_any_uri().is_some()); /// # @@ -1338,19 +1335,22 @@ impl AnyBase { /// /// ``` /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::base::AnyBase; + /// # use activitystreams_new::{base::AnyBase, uri}; /// # - /// let mut any_base = AnyBase::from_xsd_any_uri("https://example.com".parse()?); + /// let mut any_base = AnyBase::from_xsd_any_uri(uri!("https://example.com")); /// - /// any_base.set_xsd_string("hi".into()); + /// any_base.set_xsd_string("hi"); /// /// assert!(any_base.take_xsd_string().is_some()); /// # /// # Ok(()) /// # } /// ``` - pub fn set_xsd_string(&mut self, xsd_string: String) { - self.0 = Either::Right(xsd_string); + pub fn set_xsd_string(&mut self, xsd_string: T) + where + T: Into, + { + self.0 = Either::Right(xsd_string.into()); } /// Replace the object with the provided `Base` @@ -1377,8 +1377,8 @@ impl AnyBase { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// use activitystreams_new::base::AnyBase; - /// let any_base = AnyBase::from_xsd_any_uri("https://example.com".parse()?); + /// use activitystreams_new::{base::AnyBase, uri}; + /// let any_base = AnyBase::from_xsd_any_uri(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -1444,13 +1444,16 @@ impl OneOrMany { /// Get the ID from a single object if there is only one object /// /// ```rust - /// # use activitystreams_new::{base::Base, primitives::{OneOrMany, XsdAnyUri}}; + /// # fn main() -> Result<(), anyhow::Error> { + /// # use activitystreams_new::{base::Base, primitives::OneOrMany, uri}; /// # let mut base = Base::::new(); - /// # let id: XsdAnyUri = "https://example.com".parse().unwrap(); + /// # let id = uri!("https://example.com"); /// # base.id = Some(id.clone()); - /// # let base = OneOrMany::from_base(base.into_generic().unwrap().into()); + /// # let base = OneOrMany::from_base(base.into_generic()?.into()); /// # /// assert!(base.as_single_id() == Some(&id)); + /// # Ok(()) + /// # } /// ``` pub fn as_single_id(&self) -> Option<&XsdAnyUri> { self.as_one().and_then(|one| one.id()) @@ -1459,13 +1462,16 @@ impl OneOrMany { /// Check if there's only one ID, and if it equals `id` /// /// ```rust - /// # use activitystreams_new::{base::Base, primitives::{OneOrMany, XsdAnyUri}}; + /// # fn main() -> Result<(), anyhow::Error> { + /// # use activitystreams_new::{base::Base, primitives::OneOrMany, uri}; /// # let mut base = Base::::new(); - /// # let id: XsdAnyUri = "https://example.com".parse().unwrap(); + /// # let id = uri!("https://example.com"); /// # base.id = Some(id.clone()); - /// # let base = OneOrMany::from_base(base.into_generic().unwrap().into()); + /// # let base = OneOrMany::from_base(base.into_generic()?.into()); /// # /// assert!(base.is_single_id(&id)); + /// # Ok(()) + /// # } /// ``` pub fn is_single_id(&self, id: &XsdAnyUri) -> bool { self.as_single_id() == Some(id) @@ -1474,12 +1480,15 @@ impl OneOrMany { /// Get the kind of a single object if there is only one object /// /// ```rust + /// # fn main() -> Result<(), anyhow::Error> { /// # use activitystreams_new::{base::Base, primitives::OneOrMany}; /// # let mut base = Base::new(); /// # base.kind = Some(String::from("Person")); - /// # let base = OneOrMany::from_base(base.into_generic().unwrap().into()); + /// # let base = OneOrMany::from_base(base.into_generic()?.into()); /// # /// assert!(base.as_single_kind_str() == Some("Person")); + /// # Ok(()) + /// # } /// ``` pub fn as_single_kind(&self) -> Option<&serde_json::Value> { self.as_one().and_then(|one| one.kind()) @@ -1489,12 +1498,15 @@ impl OneOrMany { /// /// This returns None if the kind is not present, or not a String /// ``` + /// # fn main() -> Result<(), anyhow::Error> { /// # use activitystreams_new::{base::Base, primitives::OneOrMany}; /// # let mut base = Base::new(); /// # base.kind = Some(String::from("Person")); - /// # let base = OneOrMany::from_base(base.into_generic().unwrap().into()); + /// # let base = OneOrMany::from_base(base.into_generic()?.into()); /// # /// assert!(base.as_single_kind_str() == Some("Person")); + /// # Ok(()) + /// # } /// ``` pub fn as_single_kind_str(&self) -> Option<&str> { self.as_one().and_then(|one| one.kind_str()) @@ -1505,12 +1517,15 @@ impl OneOrMany { /// This returns False if the kind is not present, or not a String /// /// ``` + /// # fn main() -> Result<(), anyhow::Error> { /// # use activitystreams_new::{base::Base, primitives::OneOrMany}; /// # let mut base = Base::new(); /// # base.kind = Some(String::from("Person")); - /// # let base = OneOrMany::from_base(base.into_generic().unwrap().into()); + /// # let base = OneOrMany::from_base(base.into_generic()?.into()); /// # /// assert!(base.is_single_kind("Person")); + /// # Ok(()) + /// # } /// ``` pub fn is_single_kind(&self, kind: &str) -> bool { self.as_single_kind_str() == Some(kind) @@ -1520,9 +1535,9 @@ impl OneOrMany { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::primitives::OneOrMany; + /// # use activitystreams_new::{primitives::OneOrMany, uri}; /// # - /// let one = OneOrMany::from_xsd_any_uri("https://example.com".parse()?); + /// let one = OneOrMany::from_xsd_any_uri(uri!("https://example.com")); /// /// assert!(one.as_single_xsd_any_uri().is_some()); /// # @@ -1564,9 +1579,9 @@ impl OneOrMany { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::primitives::OneOrMany; + /// # use activitystreams_new::{primitives::OneOrMany, uri}; /// # - /// let one = OneOrMany::from_xsd_any_uri("https://example.com".parse()?); + /// let one = OneOrMany::from_xsd_any_uri(uri!("https://example.com")); /// /// assert!(one.single_xsd_any_uri().is_some()); /// # @@ -1608,9 +1623,9 @@ impl OneOrMany { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// use activitystreams_new::primitives::OneOrMany; + /// use activitystreams_new::{primitives::OneOrMany, uri}; /// - /// let one = OneOrMany::from_xsd_any_uri("https://example.com".parse()?); + /// let one = OneOrMany::from_xsd_any_uri(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` diff --git a/src/collection.rs b/src/collection.rs index f6fac4d..c636803 100644 --- a/src/collection.rs +++ b/src/collection.rs @@ -6,19 +6,19 @@ //! collection::OrderedCollection, //! context, //! prelude::*, -//! primitives::XsdAnyUri, +//! uri, //! }; //! //! let mut collection = OrderedCollection::new(vec![ -//! "https://example.com/notes/1234".parse::()?.into(), +//! uri!("https://example.com/notes/1234").into(), //! ]); //! //! collection //! .set_total_items(1) -//! .set_current("https://example.com/notes/1234".parse::()?) -//! .set_first("https://example.com/notes/1234".parse::()?) -//! .set_last("https://example.com/notes/1234".parse::()?) -//! .set_id("https://example.com/collections/1234".parse()?) +//! .set_current(uri!("https://example.com/notes/1234")) +//! .set_first(uri!("https://example.com/notes/1234")) +//! .set_last(uri!("https://example.com/notes/1234")) +//! .set_id(uri!("https://example.com/collections/1234")) //! .set_context(context()); //! # Ok(()) //! # } @@ -101,14 +101,10 @@ pub trait CollectionExt: AsCollection { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{ - /// # context, - /// # collection::UnorderedCollection, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::UnorderedCollection, uri}; /// # let mut collection = UnorderedCollection::new(vec![context().into()]); /// - /// collection.set_items("https://example.com".parse::()?); + /// collection.set_items(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -127,16 +123,12 @@ pub trait CollectionExt: AsCollection { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{ - /// # context, - /// # collection::UnorderedCollection, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::UnorderedCollection, uri}; /// # let mut collection = UnorderedCollection::new(vec![context().into()]); /// /// collection.set_many_items(vec![ - /// "https://example.com/one".parse::()?, - /// "https://example.com/two".parse()?, + /// uri!("https://example.com/one"), + /// uri!("https://example.com/two"), /// ]); /// # Ok(()) /// # } @@ -158,16 +150,12 @@ pub trait CollectionExt: AsCollection { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{ - /// # context, - /// # collection::UnorderedCollection, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::UnorderedCollection, uri}; /// # let mut collection = UnorderedCollection::new(vec![context().into()]); /// /// collection - /// .add_items("https://example.com/one".parse::()?) - /// .add_items("https://example.com/two".parse::()?); + /// .add_items(uri!("https://example.com/one")) + /// .add_items(uri!("https://example.com/two")); /// # Ok(()) /// # } /// ``` @@ -182,11 +170,7 @@ pub trait CollectionExt: AsCollection { /// Fetch the total_items of the current object /// /// ```rust - /// # use activitystreams_new::{ - /// # context, - /// # collection::UnorderedCollection, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::UnorderedCollection}; /// # let mut collection = UnorderedCollection::new(vec![context().into()]); /// use activitystreams_new::prelude::*; /// @@ -206,11 +190,7 @@ pub trait CollectionExt: AsCollection { /// This overwrites the contents of total_items /// /// ```rust - /// # use activitystreams_new::{ - /// # context, - /// # collection::UnorderedCollection, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::UnorderedCollection}; /// # let mut collection = UnorderedCollection::new(vec![context().into()]); /// use activitystreams_new::prelude::*; /// @@ -227,11 +207,7 @@ pub trait CollectionExt: AsCollection { /// Take the total_items of the current object, leaving nothing /// /// ```rust - /// # use activitystreams_new::{ - /// # context, - /// # collection::UnorderedCollection, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::UnorderedCollection}; /// # let mut collection = UnorderedCollection::new(vec![context().into()]); /// use activitystreams_new::prelude::*; /// @@ -246,11 +222,7 @@ pub trait CollectionExt: AsCollection { /// Delete the total_items from the current object /// /// ```rust - /// # use activitystreams_new::{ - /// # context, - /// # collection::UnorderedCollection, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::UnorderedCollection}; /// # let mut collection = UnorderedCollection::new(vec![context().into()]); /// # collection.set_total_items(5); /// use activitystreams_new::prelude::*; @@ -267,11 +239,7 @@ pub trait CollectionExt: AsCollection { /// Fetch the current field for the current object /// /// ```rust - /// # use activitystreams_new::{ - /// # context, - /// # collection::UnorderedCollection, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::UnorderedCollection}; /// # let mut collection = UnorderedCollection::new(vec![context().into()]); /// # /// use activitystreams_new::prelude::*; @@ -293,16 +261,12 @@ pub trait CollectionExt: AsCollection { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{ - /// # context, - /// # collection::UnorderedCollection, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::UnorderedCollection, uri}; /// # let mut collection = UnorderedCollection::new(vec![context().into()]); /// # /// use activitystreams_new::prelude::*; /// - /// collection.set_current("https://example.com".parse::()?); + /// collection.set_current(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -317,11 +281,7 @@ pub trait CollectionExt: AsCollection { /// Take the current field from the current object, leaving nothing /// /// ```rust - /// # use activitystreams_new::{ - /// # context, - /// # collection::UnorderedCollection, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::UnorderedCollection}; /// # let mut collection = UnorderedCollection::new(vec![context().into()]); /// # /// use activitystreams_new::prelude::*; @@ -337,11 +297,7 @@ pub trait CollectionExt: AsCollection { /// Delete the current field from the current object /// /// ```rust - /// # use activitystreams_new::{ - /// # context, - /// # collection::UnorderedCollection, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::UnorderedCollection}; /// # let mut collection = UnorderedCollection::new(vec![context().into()]); /// # collection.set_current(context()); /// # @@ -359,11 +315,7 @@ pub trait CollectionExt: AsCollection { /// Fetch the first field for the current object /// /// ```rust - /// # use activitystreams_new::{ - /// # context, - /// # collection::UnorderedCollection, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::UnorderedCollection}; /// # let mut collection = UnorderedCollection::new(vec![context().into()]); /// # /// use activitystreams_new::prelude::*; @@ -385,16 +337,12 @@ pub trait CollectionExt: AsCollection { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{ - /// # context, - /// # collection::UnorderedCollection, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::UnorderedCollection}; /// # let mut collection = UnorderedCollection::new(vec![context().into()]); /// # - /// use activitystreams_new::prelude::*; + /// use activitystreams_new::{prelude::*, uri}; /// - /// collection.set_first("https://example.com".parse::()?); + /// collection.set_first(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -409,11 +357,7 @@ pub trait CollectionExt: AsCollection { /// Take the first field from the current object, leaving nothing /// /// ```rust - /// # use activitystreams_new::{ - /// # context, - /// # collection::UnorderedCollection, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::UnorderedCollection}; /// # let mut collection = UnorderedCollection::new(vec![context().into()]); /// # /// use activitystreams_new::prelude::*; @@ -429,11 +373,7 @@ pub trait CollectionExt: AsCollection { /// Delete the first field from the current object /// /// ```rust - /// # use activitystreams_new::{ - /// # context, - /// # collection::UnorderedCollection, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::UnorderedCollection}; /// # let mut collection = UnorderedCollection::new(vec![context().into()]); /// # collection.set_first(context()); /// # @@ -451,11 +391,7 @@ pub trait CollectionExt: AsCollection { /// Fetch the last field for the current object /// /// ```rust - /// # use activitystreams_new::{ - /// # context, - /// # collection::UnorderedCollection, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::UnorderedCollection}; /// # let mut collection = UnorderedCollection::new(vec![context().into()]); /// # /// use activitystreams_new::prelude::*; @@ -477,16 +413,12 @@ pub trait CollectionExt: AsCollection { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{ - /// # context, - /// # collection::UnorderedCollection, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::UnorderedCollection}; /// # let mut collection = UnorderedCollection::new(vec![context().into()]); /// # - /// use activitystreams_new::prelude::*; + /// use activitystreams_new::{prelude::*, uri}; /// - /// collection.set_last("https://example.com".parse::()?); + /// collection.set_last(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -501,11 +433,7 @@ pub trait CollectionExt: AsCollection { /// Take the last field from the current object, leaving nothing /// /// ```rust - /// # use activitystreams_new::{ - /// # context, - /// # collection::UnorderedCollection, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::UnorderedCollection}; /// # let mut collection = UnorderedCollection::new(vec![context().into()]); /// # /// use activitystreams_new::prelude::*; @@ -521,11 +449,7 @@ pub trait CollectionExt: AsCollection { /// Delete the last field from the current object /// /// ```rust - /// # use activitystreams_new::{ - /// # context, - /// # collection::UnorderedCollection, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::UnorderedCollection}; /// # let mut collection = UnorderedCollection::new(vec![context().into()]); /// # collection.set_last(context()); /// # @@ -551,11 +475,7 @@ pub trait CollectionPageExt: AsCollectionPage { /// Fetch the part_of field for the current object /// /// ```rust - /// # use activitystreams_new::{ - /// # context, - /// # collection::UnorderedCollectionPage, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::UnorderedCollectionPage}; /// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]); /// # /// use activitystreams_new::prelude::*; @@ -577,16 +497,12 @@ pub trait CollectionPageExt: AsCollectionPage { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{ - /// # context, - /// # collection::UnorderedCollectionPage, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::UnorderedCollectionPage}; /// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]); /// # - /// use activitystreams_new::prelude::*; + /// use activitystreams_new::{prelude::*, uri}; /// - /// collection.set_part_of("https://example.com".parse::()?); + /// collection.set_part_of(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -601,11 +517,7 @@ pub trait CollectionPageExt: AsCollectionPage { /// Take the part_of field from the current object, leaving nothing /// /// ```rust - /// # use activitystreams_new::{ - /// # context, - /// # collection::UnorderedCollectionPage, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::UnorderedCollectionPage}; /// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]); /// # /// use activitystreams_new::prelude::*; @@ -621,11 +533,7 @@ pub trait CollectionPageExt: AsCollectionPage { /// Delete the part_of field from the current object /// /// ```rust - /// # use activitystreams_new::{ - /// # context, - /// # collection::UnorderedCollectionPage, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::UnorderedCollectionPage}; /// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]); /// # collection.set_part_of(context()); /// # @@ -643,11 +551,7 @@ pub trait CollectionPageExt: AsCollectionPage { /// Fetch the next field for the current object /// /// ```rust - /// # use activitystreams_new::{ - /// # context, - /// # collection::UnorderedCollectionPage, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::UnorderedCollectionPage}; /// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]); /// # /// use activitystreams_new::prelude::*; @@ -669,16 +573,12 @@ pub trait CollectionPageExt: AsCollectionPage { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{ - /// # context, - /// # collection::UnorderedCollectionPage, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::UnorderedCollectionPage}; /// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]); /// # - /// use activitystreams_new::prelude::*; + /// use activitystreams_new::{prelude::*, uri}; /// - /// collection.set_next("https://example.com".parse::()?); + /// collection.set_next(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -693,11 +593,7 @@ pub trait CollectionPageExt: AsCollectionPage { /// Take the next field from the current object, leaving nothing /// /// ```rust - /// # use activitystreams_new::{ - /// # context, - /// # collection::UnorderedCollectionPage, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::UnorderedCollectionPage}; /// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]); /// # /// use activitystreams_new::prelude::*; @@ -713,11 +609,7 @@ pub trait CollectionPageExt: AsCollectionPage { /// Delete the next field from the current object /// /// ```rust - /// # use activitystreams_new::{ - /// # context, - /// # collection::UnorderedCollectionPage, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::UnorderedCollectionPage}; /// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]); /// # collection.set_next(context()); /// # @@ -735,11 +627,7 @@ pub trait CollectionPageExt: AsCollectionPage { /// Fetch the prev field for the current object /// /// ```rust - /// # use activitystreams_new::{ - /// # context, - /// # collection::UnorderedCollectionPage, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::UnorderedCollectionPage}; /// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]); /// # /// use activitystreams_new::prelude::*; @@ -761,16 +649,12 @@ pub trait CollectionPageExt: AsCollectionPage { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{ - /// # context, - /// # collection::UnorderedCollectionPage, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::UnorderedCollectionPage}; /// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]); /// # - /// use activitystreams_new::prelude::*; + /// use activitystreams_new::{prelude::*, uri}; /// - /// collection.set_prev("https://example.com".parse::()?); + /// collection.set_prev(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -785,11 +669,7 @@ pub trait CollectionPageExt: AsCollectionPage { /// Take the prev field from the current object, leaving nothing /// /// ```rust - /// # use activitystreams_new::{ - /// # context, - /// # collection::UnorderedCollectionPage, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::UnorderedCollectionPage}; /// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]); /// # /// use activitystreams_new::prelude::*; @@ -805,11 +685,7 @@ pub trait CollectionPageExt: AsCollectionPage { /// Delete the prev field from the current object /// /// ```rust - /// # use activitystreams_new::{ - /// # context, - /// # collection::UnorderedCollectionPage, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::UnorderedCollectionPage}; /// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]); /// # collection.set_prev(context()); /// # @@ -829,11 +705,7 @@ pub trait OrderedCollectionPageExt: AsOrderedCollectionPage { /// Fetch the start_index of the current object /// /// ```rust - /// # use activitystreams_new::{ - /// # context, - /// # collection::OrderedCollectionPage, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::OrderedCollectionPage}; /// # let mut collection = OrderedCollectionPage::new(vec![context().into()]); /// use activitystreams_new::prelude::*; /// @@ -850,11 +722,7 @@ pub trait OrderedCollectionPageExt: AsOrderedCollectionPage { /// This overwrites the contents of start_index /// /// ```rust - /// # use activitystreams_new::{ - /// # context, - /// # collection::OrderedCollectionPage, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::OrderedCollectionPage}; /// # let mut collection = OrderedCollectionPage::new(vec![context().into()]); /// use activitystreams_new::prelude::*; /// @@ -871,11 +739,7 @@ pub trait OrderedCollectionPageExt: AsOrderedCollectionPage { /// Take the start_index of the current object, leaving nothing /// /// ```rust - /// # use activitystreams_new::{ - /// # context, - /// # collection::OrderedCollectionPage, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::OrderedCollectionPage}; /// # let mut collection = OrderedCollectionPage::new(vec![context().into()]); /// use activitystreams_new::prelude::*; /// @@ -890,11 +754,7 @@ pub trait OrderedCollectionPageExt: AsOrderedCollectionPage { /// Delete the start_index from the current object /// /// ```rust - /// # use activitystreams_new::{ - /// # context, - /// # collection::OrderedCollectionPage, - /// # primitives::XsdAnyUri - /// # }; + /// # use activitystreams_new::{context, collection::OrderedCollectionPage}; /// # let mut collection = OrderedCollectionPage::new(vec![context().into()]); /// # collection.set_start_index(5); /// use activitystreams_new::prelude::*; diff --git a/src/lib.rs b/src/lib.rs index b205f58..ad8a28d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -164,14 +164,14 @@ //! bound the function like so: //! //! ```rust -//! use activitystreams_new::{base::BaseExt, context, markers::Activity}; +//! use activitystreams_new::{base::BaseExt, context, markers::Activity, uri}; //! //! fn manipulator(mut activity: T) -> Result<(), anyhow::Error> //! where //! T: Activity + BaseExt, //! { //! activity -//! .set_id("https://example.com".parse()?) +//! .set_id(uri!("https://example.com")) //! .set_context(context()); //! Ok(()) //! } @@ -205,7 +205,7 @@ //! context, //! object::{ApObject, Video}, //! prelude::*, -//! primitives::XsdAnyUri, +//! uri, //! }; //! //! fn main() -> Result<(), anyhow::Error> { @@ -213,12 +213,12 @@ //! //! video //! .set_context(context()) -//! .set_id("https://example.com/@example/lions".parse()?) +//! .set_id(uri!("https://example.com/@example/lions")) //! .set_media_type("video/webm".parse()?) -//! .set_url("https://example.com/@example/lions/video.webm".parse::()?) +//! .set_url(uri!("https://example.com/@example/lions/video.webm")) //! .set_summary("A cool video") //! .set_duration("PT4M20S".parse()?) -//! .set_shares("https://example.com/@example/lions/video.webm#shares".parse()?); +//! .set_shares(uri!("https://example.com/@example/lions/video.webm#shares")); //! //! println!("Video, {:#?}", video); //! @@ -332,47 +332,44 @@ pub mod prelude { //! ```rust //! # fn main() -> Result<(), anyhow::Error> { //! use activitystreams_new::{ - //! activity::{kind::CreateType, Create}, - //! actor::{kind::PersonType, ApActor, Person}, + //! activity::Create, + //! actor::{ApActor, Person}, //! context, //! prelude::*, - //! primitives::XsdAnyUri, //! public, - //! object::{ - //! kind::{ImageType, VideoType}, - //! ApObject, Image, Video - //! }, - //! security + //! object::{ApObject, Image, Video}, + //! security, + //! uri, //! }; //! //! let mut person = ApActor::new( - //! "http://localhost:8080/inbox".parse()?, + //! uri!("http://localhost:8080/inbox"), //! Person::new(), //! ); //! person - //! .set_outbox("http:/localhost:8080/outbox".parse()?) + //! .set_outbox(uri!("http:/localhost:8080/outbox")) //! .set_name("Demo Account") //! .set_preferred_username("demo") - //! .set_id("https://localhost:8080/actor".parse()?) - //! .set_url("https://localhost:8080/actor".parse::()?); + //! .set_id(uri!("https://localhost:8080/actor")) + //! .set_url(uri!("https://localhost:8080/actor")); //! //! let mut preview = Image::new(); //! //! preview - //! .set_url("https://localhost:8080/preview.png".parse::()?) + //! .set_url(uri!("https://localhost:8080/preview.png")) //! .set_media_type("image/png".parse()?) - //! .set_id("https://localhostst:8080/preview.png".parse()?); + //! .set_id(uri!("https://localhostst:8080/preview.png")); //! //! let mut video = ApObject::new(Video::new()); //! //! video - //! .set_id("http://localhost:8080/video.webm".parse()?) - //! .set_url("http://localhost:8080/video.webm".parse::()?) + //! .set_id(uri!("http://localhost:8080/video.webm")) + //! .set_url(uri!("http://localhost:8080/video.webm")) //! .set_media_type("video/webm".parse()?) //! .set_summary("A cool video") //! .set_preview(preview.into_any_base()?) //! .set_duration("PT4M20S".parse()?) - //! .set_shares("http://localhost:8080/video.webm#shares".parse()?); + //! .set_shares(uri!("http://localhost:8080/video.webm#shares")); //! //! let mut activity = Create::new( //! person.into_any_base()?, @@ -398,3 +395,24 @@ pub mod prelude { object::{ApObjectExt, ObjectExt, PlaceExt, ProfileExt, RelationshipExt, TombstoneExt}, }; } + +/// A macro to shorten the `string.parse::()?` calls inevitably made in downstream code +/// +/// ```rust +/// use activitystreams_new::uri; +/// +/// fn fallible() -> Result<(), anyhow::Error> { +/// let my_uri = uri!("https://example.com"); +/// Ok(()) +/// } +/// +/// # fn main() -> Result<(), anyhow::Error> { fallible() } +/// ``` +#[macro_export] +macro_rules! uri { + ( $x:expr ) => {{ + use activitystreams::primitives::XsdAnyUri; + + $x.parse::()? + }}; +} diff --git a/src/link.rs b/src/link.rs index 668ae98..846f934 100644 --- a/src/link.rs +++ b/src/link.rs @@ -6,15 +6,15 @@ //! link::Mention, //! object::Image, //! prelude::*, -//! primitives::XsdAnyUri, +//! uri, //! }; //! //! let mut mention = Mention::new(); //! //! mention -//! .set_href("https://example.com".parse()?) -//! .set_hreflang("en".into()) -//! .set_rel("link".into()) +//! .set_href(uri!("https://example.com")) +//! .set_hreflang("en") +//! .set_rel("link") //! .set_preview(Image::new().into_any_base()?); //! # //! # Ok(()) @@ -80,12 +80,12 @@ pub trait LinkExt: AsLink { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::link::Mention; + /// # use activitystreams_new::{link::Mention, uri}; /// # let mut mention = Mention::new(); /// # /// use activitystreams_new::prelude::*; /// - /// mention.set_href("https://example.com".parse()?); + /// mention.set_href(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -114,9 +114,9 @@ pub trait LinkExt: AsLink { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::link::Mention; + /// # use activitystreams_new::{link::Mention, uri}; /// # let mut mention = Mention::new(); - /// # mention.set_href("https://example.com".parse()?); + /// # mention.set_href(uri!("https://example.com")); /// # /// use activitystreams_new::prelude::*; /// @@ -158,10 +158,13 @@ pub trait LinkExt: AsLink { /// # /// use activitystreams_new::prelude::*; /// - /// mention.set_hreflang("en".into()); + /// mention.set_hreflang("en"); /// ``` - fn set_hreflang(&mut self, hreflang: String) -> &mut Self { - self.link_mut().hreflang = Some(hreflang); + fn set_hreflang(&mut self, hreflang: T) -> &mut Self + where + T: Into, + { + self.link_mut().hreflang = Some(hreflang.into()); self } @@ -187,7 +190,7 @@ pub trait LinkExt: AsLink { /// # fn main() -> Result<(), anyhow::Error> { /// # use activitystreams_new::link::Mention; /// # let mut mention = Mention::new(); - /// # mention.set_hreflang("https://example.com".parse()?); + /// # mention.set_hreflang("en"); /// # /// use activitystreams_new::prelude::*; /// @@ -229,10 +232,13 @@ pub trait LinkExt: AsLink { /// # /// use activitystreams_new::prelude::*; /// - /// mention.set_rel("link".into()); + /// mention.set_rel("link"); /// ``` - fn set_rel(&mut self, rel: String) -> &mut Self { - self.link_mut().rel = Some(rel.into()); + fn set_rel(&mut self, rel: T) -> &mut Self + where + T: Into, + { + self.link_mut().rel = Some(rel.into().into()); self } @@ -304,7 +310,7 @@ pub trait LinkExt: AsLink { /// ```rust /// # use activitystreams_new::link::Mention; /// # let mut mention = Mention::new(); - /// # mention.set_rel("link".into()); + /// # mention.set_rel("link"); /// # /// use activitystreams_new::prelude::*; /// diff --git a/src/object.rs b/src/object.rs index 1eb15cb..c4774ff 100644 --- a/src/object.rs +++ b/src/object.rs @@ -5,16 +5,16 @@ //! use activitystreams_new::{ //! object::Image, //! prelude::*, -//! primitives::XsdAnyUri, +//! uri, //! }; //! //! let mut image = Image::new(); //! //! image -//! .set_url("https://example.com/image.png".parse::()?) -//! .set_attributed_to("https://example.com/actor".parse::()?) -//! .set_generator("https://example.com/image-generator".parse::()?) -//! .set_icon("https://example.com/icon.png".parse::()?); +//! .set_url(uri!("https://example.com/image.png")) +//! .set_attributed_to(uri!("https://example.com/actor")) +//! .set_generator(uri!("https://example.com/image-generator")) +//! .set_icon(uri!("https://example.com/icon.png")); //! # //! # Ok(()) //! # } @@ -138,10 +138,10 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// - /// video.set_attachment("https://example.com".parse::()?); + /// video.set_attachment(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -160,12 +160,12 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// /// video.set_many_attachments(vec![ - /// "https://example.com/one".parse::()?, - /// "https://example.com/two".parse()?, + /// uri!("https://example.com/one"), + /// uri!("https://example.com/two"), /// ]); /// # Ok(()) /// # } @@ -187,12 +187,12 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// /// video - /// .add_attachment("https://example.com/one".parse::()?) - /// .add_attachment("https://example.com/two".parse::()?); + /// .add_attachment(uri!("https://example.com/one")) + /// .add_attachment(uri!("https://example.com/two")); /// # Ok(()) /// # } /// ``` @@ -231,9 +231,9 @@ pub trait ObjectExt: AsObject { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); - /// # video.set_attachment("https://example.com".parse::()?); + /// # video.set_attachment(uri!("https://example.com")); /// # /// use activitystreams_new::prelude::*; /// @@ -274,10 +274,10 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// - /// video.set_attributed_to("https://example.com".parse::()?); + /// video.set_attributed_to(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -296,12 +296,12 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// /// video.set_many_attributed_tos(vec![ - /// "https://example.com/one".parse::()?, - /// "https://example.com/two".parse()?, + /// uri!("https://example.com/one"), + /// uri!("https://example.com/two"), /// ]); /// # Ok(()) /// # } @@ -323,12 +323,12 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// /// video - /// .add_attributed_to("https://example.com/one".parse::()?) - /// .add_attributed_to("https://example.com/two".parse::()?); + /// .add_attributed_to(uri!("https://example.com/one")) + /// .add_attributed_to(uri!("https://example.com/two")); /// # Ok(()) /// # } /// ``` @@ -367,9 +367,9 @@ pub trait ObjectExt: AsObject { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); - /// # video.set_attributed_to("https://example.com".parse::()?); + /// # video.set_attributed_to(uri!("https://example.com")); /// # /// use activitystreams_new::prelude::*; /// @@ -410,10 +410,10 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// - /// video.set_audience("https://example.com".parse::()?); + /// video.set_audience(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -430,12 +430,12 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// /// video.set_many_audiences(vec![ - /// "https://example.com/one".parse::()?, - /// "https://example.com/two".parse()?, + /// uri!("https://example.com/one"), + /// uri!("https://example.com/two"), /// ]); /// # Ok(()) /// # } @@ -457,12 +457,12 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// /// video - /// .add_audience("https://example.com/one".parse::()?) - /// .add_audience("https://example.com/two".parse::()?); + /// .add_audience(uri!("https://example.com/one")) + /// .add_audience(uri!("https://example.com/two")); /// # Ok(()) /// # } /// ``` @@ -501,9 +501,9 @@ pub trait ObjectExt: AsObject { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); - /// # video.set_audience("https://example.com".parse::()?); + /// # video.set_audience(uri!("https://example.com")); /// # /// use activitystreams_new::prelude::*; /// @@ -786,10 +786,10 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// - /// video.set_url("https://example.com".parse::()?); + /// video.set_url(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -808,12 +808,12 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// /// video.set_many_urls(vec![ - /// "https://example.com/one".parse::()?, - /// "https://example.com/two".parse()?, + /// uri!("https://example.com/one"), + /// uri!("https://example.com/two"), /// ]); /// # Ok(()) /// # } @@ -835,12 +835,12 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// /// video - /// .add_url("https://example.com/one".parse::()?) - /// .add_url("https://example.com/two".parse::()?); + /// .add_url(uri!("https://example.com/one")) + /// .add_url(uri!("https://example.com/two")); /// # Ok(()) /// # } /// ``` @@ -879,9 +879,9 @@ pub trait ObjectExt: AsObject { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); - /// # video.set_url("https://example.com".parse::()?); + /// # video.set_url(uri!("https://example.com")); /// # /// use activitystreams_new::prelude::*; /// @@ -922,10 +922,10 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// - /// video.set_generator("https://example.com".parse::()?); + /// video.set_generator(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -944,12 +944,12 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// /// video.set_many_generators(vec![ - /// "https://example.com/one".parse::()?, - /// "https://example.com/two".parse()?, + /// uri!("https://example.com/one"), + /// uri!("https://example.com/two"), /// ]); /// # Ok(()) /// # } @@ -971,12 +971,12 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// /// video - /// .add_generator("https://example.com/one".parse::()?) - /// .add_generator("https://example.com/two".parse::()?); + /// .add_generator(uri!("https://example.com/one")) + /// .add_generator(uri!("https://example.com/two")); /// # Ok(()) /// # } /// ``` @@ -1015,9 +1015,9 @@ pub trait ObjectExt: AsObject { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); - /// # video.set_generator("https://example.com".parse::()?); + /// # video.set_generator(uri!("https://example.com")); /// # /// use activitystreams_new::prelude::*; /// @@ -1058,10 +1058,10 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// - /// video.set_icon("https://example.com".parse::()?); + /// video.set_icon(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -1080,12 +1080,12 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// /// video.set_many_icons(vec![ - /// "https://example.com/one".parse::()?, - /// "https://example.com/two".parse()?, + /// uri!("https://example.com/one"), + /// uri!("https://example.com/two"), /// ]); /// # Ok(()) /// # } @@ -1107,12 +1107,12 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// /// video - /// .add_icon("https://example.com/one".parse::()?) - /// .add_icon("https://example.com/two".parse::()?); + /// .add_icon(uri!("https://example.com/one")) + /// .add_icon(uri!("https://example.com/two")); /// # Ok(()) /// # } /// ``` @@ -1151,9 +1151,9 @@ pub trait ObjectExt: AsObject { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); - /// # video.set_icon("https://example.com".parse::()?); + /// # video.set_icon(uri!("https://example.com")); /// # /// use activitystreams_new::prelude::*; /// @@ -1194,10 +1194,10 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// - /// video.set_image("https://example.com".parse::()?); + /// video.set_image(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -1216,12 +1216,12 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// /// video.set_many_images(vec![ - /// "https://example.com/one".parse::()?, - /// "https://example.com/two".parse()?, + /// uri!("https://example.com/one"), + /// uri!("https://example.com/two"), /// ]); /// # Ok(()) /// # } @@ -1243,12 +1243,12 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// /// video - /// .add_image("https://example.com/one".parse::()?) - /// .add_image("https://example.com/two".parse::()?); + /// .add_image(uri!("https://example.com/one")) + /// .add_image(uri!("https://example.com/two")); /// # Ok(()) /// # } /// ``` @@ -1287,9 +1287,9 @@ pub trait ObjectExt: AsObject { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); - /// # video.set_image("https://example.com".parse::()?); + /// # video.set_image(uri!("https://example.com")); /// # /// use activitystreams_new::prelude::*; /// @@ -1330,10 +1330,10 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// - /// video.set_location("https://example.com".parse::()?); + /// video.set_location(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -1352,12 +1352,12 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// /// video.set_many_locations(vec![ - /// "https://example.com/one".parse::()?, - /// "https://example.com/two".parse()?, + /// uri!("https://example.com/one"), + /// uri!("https://example.com/two"), /// ]); /// # Ok(()) /// # } @@ -1379,12 +1379,12 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// /// video - /// .add_location("https://example.com/one".parse::()?) - /// .add_location("https://example.com/two".parse::()?); + /// .add_location(uri!("https://example.com/one")) + /// .add_location(uri!("https://example.com/two")); /// # Ok(()) /// # } /// ``` @@ -1423,9 +1423,9 @@ pub trait ObjectExt: AsObject { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); - /// # video.set_location("https://example.com".parse::()?); + /// # video.set_location(uri!("https://example.com")); /// # /// use activitystreams_new::prelude::*; /// @@ -1466,10 +1466,10 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// - /// video.set_tag("https://example.com".parse::()?); + /// video.set_tag(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -1488,12 +1488,12 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// /// video.set_many_tags(vec![ - /// "https://example.com/one".parse::()?, - /// "https://example.com/two".parse()?, + /// uri!("https://example.com/one"), + /// uri!("https://example.com/two"), /// ]); /// # Ok(()) /// # } @@ -1515,12 +1515,12 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// /// video - /// .add_tag("https://example.com/one".parse::()?) - /// .add_tag("https://example.com/two".parse::()?); + /// .add_tag(uri!("https://example.com/one")) + /// .add_tag(uri!("https://example.com/two")); /// # Ok(()) /// # } /// ``` @@ -1559,9 +1559,9 @@ pub trait ObjectExt: AsObject { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); - /// # video.set_tag("https://example.com".parse::()?); + /// # video.set_tag(uri!("https://example.com")); /// # /// use activitystreams_new::prelude::*; /// @@ -1977,10 +1977,10 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// - /// video.set_in_reply_to("https://example.com".parse::()?); + /// video.set_in_reply_to(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -1999,12 +1999,12 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// /// video.set_many_in_reply_tos(vec![ - /// "https://example.com/one".parse::()?, - /// "https://example.com/two".parse()?, + /// uri!("https://example.com/one"), + /// uri!("https://example.com/two"), /// ]); /// # Ok(()) /// # } @@ -2026,12 +2026,12 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// /// video - /// .add_in_reply_to("https://example.com/one".parse::()?) - /// .add_in_reply_to("https://example.com/two".parse::()?); + /// .add_in_reply_to(uri!("https://example.com/one")) + /// .add_in_reply_to(uri!("https://example.com/two")); /// # Ok(()) /// # } /// ``` @@ -2070,9 +2070,9 @@ pub trait ObjectExt: AsObject { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); - /// # video.set_in_reply_to("https://example.com".parse::()?); + /// # video.set_in_reply_to(uri!("https://example.com")); /// # /// use activitystreams_new::prelude::*; /// @@ -2113,10 +2113,10 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// - /// video.set_replies("https://example.com".parse::()?); + /// video.set_replies(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -2135,12 +2135,12 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// /// video.set_many_replies(vec![ - /// "https://example.com/one".parse::()?, - /// "https://example.com/two".parse()?, + /// uri!("https://example.com/one"), + /// uri!("https://example.com/two"), /// ]); /// # Ok(()) /// # } @@ -2162,12 +2162,12 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// /// video - /// .add_replies("https://example.com/one".parse::()?) - /// .add_replies("https://example.com/two".parse::()?); + /// .add_replies(uri!("https://example.com/one")) + /// .add_replies(uri!("https://example.com/two")); /// # Ok(()) /// # } /// ``` @@ -2206,9 +2206,9 @@ pub trait ObjectExt: AsObject { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); - /// # video.set_replies("https://example.com".parse::()?); + /// # video.set_replies(uri!("https://example.com")); /// # /// use activitystreams_new::prelude::*; /// @@ -2249,10 +2249,10 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// - /// video.set_to("https://example.com".parse::()?); + /// video.set_to(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -2271,12 +2271,12 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// /// video.set_many_tos(vec![ - /// "https://example.com/one".parse::()?, - /// "https://example.com/two".parse()?, + /// uri!("https://example.com/one"), + /// uri!("https://example.com/two"), /// ]); /// # Ok(()) /// # } @@ -2298,12 +2298,12 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// /// video - /// .add_to("https://example.com/one".parse::()?) - /// .add_to("https://example.com/two".parse::()?); + /// .add_to(uri!("https://example.com/one")) + /// .add_to(uri!("https://example.com/two")); /// # Ok(()) /// # } /// ``` @@ -2342,9 +2342,9 @@ pub trait ObjectExt: AsObject { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); - /// # video.set_to("https://example.com".parse::()?); + /// # video.set_to(uri!("https://example.com")); /// # /// use activitystreams_new::prelude::*; /// @@ -2385,10 +2385,10 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// - /// video.set_bto("https://example.com".parse::()?); + /// video.set_bto(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -2407,12 +2407,12 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// /// video.set_many_btos(vec![ - /// "https://example.com/one".parse::()?, - /// "https://example.com/two".parse()?, + /// uri!("https://example.com/one"), + /// uri!("https://example.com/two"), /// ]); /// # Ok(()) /// # } @@ -2434,12 +2434,12 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// /// video - /// .add_bto("https://example.com/one".parse::()?) - /// .add_bto("https://example.com/two".parse::()?); + /// .add_bto(uri!("https://example.com/one")) + /// .add_bto(uri!("https://example.com/two")); /// # Ok(()) /// # } /// ``` @@ -2478,9 +2478,9 @@ pub trait ObjectExt: AsObject { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); - /// # video.set_bto("https://example.com".parse::()?); + /// # video.set_bto(uri!("https://example.com")); /// # /// use activitystreams_new::prelude::*; /// @@ -2521,10 +2521,10 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// - /// video.set_cc("https://example.com".parse::()?); + /// video.set_cc(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -2543,12 +2543,12 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// /// video.set_many_ccs(vec![ - /// "https://example.com/one".parse::()?, - /// "https://example.com/two".parse()?, + /// uri!("https://example.com/one"), + /// uri!("https://example.com/two"), /// ]); /// # Ok(()) /// # } @@ -2570,12 +2570,12 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// /// video - /// .add_cc("https://example.com/one".parse::()?) - /// .add_cc("https://example.com/two".parse::()?); + /// .add_cc(uri!("https://example.com/one")) + /// .add_cc(uri!("https://example.com/two")); /// # Ok(()) /// # } /// ``` @@ -2614,9 +2614,9 @@ pub trait ObjectExt: AsObject { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); - /// # video.set_cc("https://example.com".parse::()?); + /// # video.set_cc(uri!("https://example.com")); /// # /// use activitystreams_new::prelude::*; /// @@ -2657,10 +2657,10 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// - /// video.set_bcc("https://example.com".parse::()?); + /// video.set_bcc(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -2679,12 +2679,12 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// /// video.set_many_bcc(vec![ - /// "https://example.com/one".parse::()?, - /// "https://example.com/two".parse()?, + /// uri!("https://example.com/one"), + /// uri!("https://example.com/two"), /// ]); /// # Ok(()) /// # } @@ -2706,12 +2706,12 @@ pub trait ObjectExt: AsObject { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); /// /// video - /// .add_bcc("https://example.com/one".parse::()?) - /// .add_bcc("https://example.com/two".parse::()?); + /// .add_bcc(uri!("https://example.com/one")) + /// .add_bcc(uri!("https://example.com/two")); /// # Ok(()) /// # } /// ``` @@ -2750,9 +2750,9 @@ pub trait ObjectExt: AsObject { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{object::Video, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Video, uri}; /// # let mut video = Video::new(); - /// # video.set_bcc("https://example.com".parse::()?); + /// # video.set_bcc(uri!("https://example.com")); /// # /// use activitystreams_new::prelude::*; /// @@ -2802,9 +2802,9 @@ pub trait ApObjectExt: AsApObject { /// # use activitystreams_new::object::{ApObject, Video}; /// # let mut video = ApObject::new(Video::new()); /// # - /// use activitystreams_new::prelude::*; + /// use activitystreams_new::{prelude::*, uri}; /// - /// video.set_shares("https://example.com".parse()?); + /// video.set_shares(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -2875,9 +2875,9 @@ pub trait ApObjectExt: AsApObject { /// # use activitystreams_new::object::{ApObject, Video}; /// # let mut video = ApObject::new(Video::new()); /// # - /// use activitystreams_new::prelude::*; + /// use activitystreams_new::{prelude::*, uri}; /// - /// video.set_likes("https://example.com".parse()?); + /// video.set_likes(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -2945,12 +2945,12 @@ pub trait ApObjectExt: AsApObject { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{object::{ApObject, Video}, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::{ApObject, Video}, uri}; /// # let mut video = ApObject::new(Video::new()); /// # /// use activitystreams_new::prelude::*; /// - /// video.set_source("https://example.com".parse::()?); + /// video.set_source(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -3021,12 +3021,12 @@ pub trait ApObjectExt: AsApObject { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{object::{ApObject, Video}, primitives::XsdAnyUri}; + /// # use activitystreams_new::object::{ApObject, Video}; /// # let mut video = ApObject::new(Video::new()); /// # - /// use activitystreams_new::prelude::*; + /// use activitystreams_new::{prelude::*, uri}; /// - /// video.set_upload_media("https://example.com".parse()?); + /// video.set_upload_media(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -3041,14 +3041,14 @@ pub trait ApObjectExt: AsApObject { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{object::{ApObject, Video}, primitives::XsdAnyUri}; + /// # use activitystreams_new::object::{ApObject, Video}; /// # let mut video = ApObject::new(Video::new()); /// # - /// use activitystreams_new::prelude::*; + /// use activitystreams_new::{prelude::*, uri}; /// /// video.set_many_upload_medias(vec![ - /// "https://example.com/one".parse()?, - /// "https://example.com/two".parse()?, + /// uri!("https://example.com/one"), + /// uri!("https://example.com/two"), /// ]); /// # Ok(()) /// # } @@ -3068,14 +3068,14 @@ pub trait ApObjectExt: AsApObject { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{object::{ApObject, Video}, primitives::XsdAnyUri}; + /// # use activitystreams_new::object::{ApObject, Video}; /// # let mut video = ApObject::new(Video::new()); /// # - /// use activitystreams_new::prelude::*; + /// use activitystreams_new::{prelude::*, uri}; /// /// video - /// .add_upload_media("https://example.com/one".parse()?) - /// .add_upload_media("https://example.com/two".parse()?); + /// .add_upload_media(uri!("https://example.com/one")) + /// .add_upload_media(uri!("https://example.com/two")); /// # Ok(()) /// # } /// ``` @@ -3581,12 +3581,12 @@ pub trait ProfileExt: AsProfile { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{object::Profile, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Profile, uri}; /// # let mut profile = Profile::new(); /// # /// use activitystreams_new::prelude::*; /// - /// profile.set_describes("https://example.com".parse::()?); + /// profile.set_describes(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -3661,12 +3661,12 @@ pub trait RelationshipExt: AsRelationship { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{object::Relationship, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Relationship, uri}; /// # let mut relationship = Relationship::new(); /// # /// use activitystreams_new::prelude::*; /// - /// relationship.set_subject("https://example.com".parse::()?); + /// relationship.set_subject(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -3735,10 +3735,10 @@ pub trait RelationshipExt: AsRelationship { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Relationship, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Relationship, uri}; /// # let mut relationship = Relationship::new(); /// - /// relationship.set_object("https://example.com".parse::()?); + /// relationship.set_object(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -3757,12 +3757,12 @@ pub trait RelationshipExt: AsRelationship { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Relationship, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Relationship, uri}; /// # let mut relationship = Relationship::new(); /// /// relationship.set_many_objects(vec![ - /// "https://example.com/one".parse::()?, - /// "https://example.com/two".parse()?, + /// uri!("https://example.com/one"), + /// uri!("https://example.com/two"), /// ]); /// # Ok(()) /// # } @@ -3784,12 +3784,12 @@ pub trait RelationshipExt: AsRelationship { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Relationship, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Relationship, uri}; /// # let mut relationship = Relationship::new(); /// /// relationship - /// .add_object("https://example.com/one".parse::()?) - /// .add_object("https://example.com/two".parse::()?); + /// .add_object(uri!("https://example.com/one")) + /// .add_object(uri!("https://example.com/two")); /// # Ok(()) /// # } /// ``` @@ -3828,9 +3828,9 @@ pub trait RelationshipExt: AsRelationship { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{object::Relationship, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Relationship, uri}; /// # let mut relationship = Relationship::new(); - /// # relationship.set_object("https://example.com".parse::()?); + /// # relationship.set_object(uri!("https://example.com")); /// # /// use activitystreams_new::prelude::*; /// @@ -3868,10 +3868,10 @@ pub trait RelationshipExt: AsRelationship { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Relationship, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Relationship, uri}; /// # let mut relationship = Relationship::new(); /// - /// relationship.set_relationship("https://example.com".parse::()?); + /// relationship.set_relationship(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -3890,12 +3890,12 @@ pub trait RelationshipExt: AsRelationship { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Relationship, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Relationship, uri}; /// # let mut relationship = Relationship::new(); /// /// relationship.set_many_relationships(vec![ - /// "https://example.com/one".parse::()?, - /// "https://example.com/two".parse()?, + /// uri!("https://example.com/one"), + /// uri!("https://example.com/two"), /// ]); /// # Ok(()) /// # } @@ -3917,12 +3917,12 @@ pub trait RelationshipExt: AsRelationship { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Relationship, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Relationship, uri}; /// # let mut relationship = Relationship::new(); /// /// relationship - /// .add_relationship("https://example.com/one".parse::()?) - /// .add_relationship("https://example.com/two".parse::()?); + /// .add_relationship(uri!("https://example.com/one")) + /// .add_relationship(uri!("https://example.com/two")); /// # Ok(()) /// # } /// ``` @@ -3961,9 +3961,9 @@ pub trait RelationshipExt: AsRelationship { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{object::Relationship, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Relationship, uri}; /// # let mut relationship = Relationship::new(); - /// # relationship.set_relationship("https://example.com".parse::()?); + /// # relationship.set_relationship(uri!("https://example.com")); /// # /// use activitystreams_new::prelude::*; /// @@ -4008,10 +4008,10 @@ pub trait TombstoneExt: AsTombstone { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Tombstone, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Tombstone, uri}; /// # let mut tombstone = Tombstone::new(); /// - /// tombstone.set_former_type("https://example.com".parse::()?); + /// tombstone.set_former_type(uri!("https://example.com")); /// # Ok(()) /// # } /// ``` @@ -4030,12 +4030,12 @@ pub trait TombstoneExt: AsTombstone { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Tombstone, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Tombstone, uri}; /// # let mut tombstone = Tombstone::new(); /// /// tombstone.set_many_former_types(vec![ - /// "https://example.com/one".parse::()?, - /// "https://example.com/two".parse()?, + /// uri!("https://example.com/one"), + /// uri!("https://example.com/two"), /// ]); /// # Ok(()) /// # } @@ -4057,12 +4057,12 @@ pub trait TombstoneExt: AsTombstone { /// ```rust /// # fn main() -> Result<(), anyhow::Error> { /// use activitystreams_new::prelude::*; - /// # use activitystreams_new::{object::Tombstone, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Tombstone, uri}; /// # let mut tombstone = Tombstone::new(); /// /// tombstone - /// .add_former_type("https://example.com/one".parse::()?) - /// .add_former_type("https://example.com/two".parse::()?); + /// .add_former_type(uri!("https://example.com/one")) + /// .add_former_type(uri!("https://example.com/two")); /// # Ok(()) /// # } /// ``` @@ -4101,9 +4101,9 @@ pub trait TombstoneExt: AsTombstone { /// /// ```rust /// # fn main() -> Result<(), anyhow::Error> { - /// # use activitystreams_new::{object::Tombstone, primitives::XsdAnyUri}; + /// # use activitystreams_new::{object::Tombstone, uri}; /// # let mut tombstone = Tombstone::new(); - /// # tombstone.set_former_type("https://example.com".parse::()?); + /// # tombstone.set_former_type(uri!("https://example.com")); /// # /// use activitystreams_new::prelude::*; ///