Introduce 'uri' macro
This commit is contained in:
parent
05a2bdc98d
commit
0979abb694
8 changed files with 541 additions and 732 deletions
|
@ -2,7 +2,7 @@ use activitystreams_new::{
|
||||||
context,
|
context,
|
||||||
object::{ApObject, Video},
|
object::{ApObject, Video},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
primitives::XsdAnyUri,
|
uri,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() -> Result<(), anyhow::Error> {
|
fn main() -> Result<(), anyhow::Error> {
|
||||||
|
@ -10,12 +10,12 @@ fn main() -> Result<(), anyhow::Error> {
|
||||||
|
|
||||||
video
|
video
|
||||||
.set_context(context())
|
.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_media_type("video/webm".parse()?)
|
||||||
.set_url("https://example.com/@example/lions/video.webm".parse::<XsdAnyUri>()?)
|
.set_url(uri!("https://example.com/@example/lions/video.webm"))
|
||||||
.set_summary("A cool video".to_owned())
|
.set_summary("A cool video".to_owned())
|
||||||
.set_duration("PT4M20S".parse()?)
|
.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);
|
println!("Video, {:#?}", video);
|
||||||
|
|
||||||
|
|
296
src/activity.rs
296
src/activity.rs
|
@ -6,18 +6,18 @@
|
||||||
//! activity::Create,
|
//! activity::Create,
|
||||||
//! context,
|
//! context,
|
||||||
//! prelude::*,
|
//! prelude::*,
|
||||||
//! primitives::XsdAnyUri,
|
//! uri,
|
||||||
//! };
|
//! };
|
||||||
//!
|
//!
|
||||||
//! let mut create = Create::new(
|
//! let mut create = Create::new(
|
||||||
//! "https://example.com/actors/abcd".parse::<XsdAnyUri>()?,
|
//! uri!("https://example.com/actors/abcd"),
|
||||||
//! "https://example.com/notes/1234".parse::<XsdAnyUri>()?,
|
//! uri!("https://example.com/notes/1234"),
|
||||||
//! );
|
//! );
|
||||||
//!
|
//!
|
||||||
//! create
|
//! create
|
||||||
//! .set_result("https://example.com/".parse::<XsdAnyUri>()?)
|
//! .set_result(uri!("https://example.com/"))
|
||||||
//! .set_instrument("https://example.com/".parse::<XsdAnyUri>()?)
|
//! .set_instrument(uri!("https://example.com/"))
|
||||||
//! .set_id("https://example.com/activities/abcd".parse()?)
|
//! .set_id(uri!("https://example.com/activities/abcd"))
|
||||||
//! .set_context(context());
|
//! .set_context(context());
|
||||||
//! # Ok(())
|
//! # Ok(())
|
||||||
//! # }
|
//! # }
|
||||||
|
@ -164,10 +164,10 @@ pub trait ActivityExt<Kind>: AsActivity<Kind> {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{activity::Question, primitives::XsdAnyUri};
|
/// # use activitystreams_new::{activity::Question, uri};
|
||||||
/// # let mut question = Question::new();
|
/// # let mut question = Question::new();
|
||||||
///
|
///
|
||||||
/// question.set_result("https://example.com".parse::<XsdAnyUri>()?);
|
/// question.set_result(uri!("https://example.com"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -186,12 +186,12 @@ pub trait ActivityExt<Kind>: AsActivity<Kind> {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{activity::Question, primitives::XsdAnyUri};
|
/// # use activitystreams_new::{activity::Question, uri};
|
||||||
/// # let mut question = Question::new();
|
/// # let mut question = Question::new();
|
||||||
///
|
///
|
||||||
/// question.set_many_results(vec![
|
/// question.set_many_results(vec![
|
||||||
/// "https://example.com/one".parse::<XsdAnyUri>()?,
|
/// uri!("https://example.com/one"),
|
||||||
/// "https://example.com/two".parse()?,
|
/// uri!("https://example.com/two"),
|
||||||
/// ]);
|
/// ]);
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
|
@ -212,13 +212,13 @@ pub trait ActivityExt<Kind>: AsActivity<Kind> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::{prelude::*, uri};
|
||||||
/// # use activitystreams_new::{activity::Question, primitives::XsdAnyUri};
|
/// # use activitystreams_new::{activity::Question};
|
||||||
/// # let mut question = Question::new();
|
/// # let mut question = Question::new();
|
||||||
///
|
///
|
||||||
/// question
|
/// question
|
||||||
/// .add_result("https://example.com/one".parse::<XsdAnyUri>()?)
|
/// .add_result(uri!("https://example.com/one"))
|
||||||
/// .add_result("https://example.com/two".parse::<XsdAnyUri>()?);
|
/// .add_result(uri!("https://example.com/two"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -257,9 +257,9 @@ pub trait ActivityExt<Kind>: AsActivity<Kind> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// # use activitystreams_new::{activity::Question, primitives::XsdAnyUri};
|
/// # use activitystreams_new::{activity::Question, uri};
|
||||||
/// # let mut question = Question::new();
|
/// # let mut question = Question::new();
|
||||||
/// # question.set_result("https://example.com".parse::<XsdAnyUri>()?);
|
/// # question.set_result(uri!("https://example.com"));
|
||||||
/// #
|
/// #
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
|
@ -300,10 +300,10 @@ pub trait ActivityExt<Kind>: AsActivity<Kind> {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{activity::Question, primitives::XsdAnyUri};
|
/// # use activitystreams_new::{activity::Question, uri};
|
||||||
/// # let mut question = Question::new();
|
/// # let mut question = Question::new();
|
||||||
///
|
///
|
||||||
/// question.set_instrument("https://example.com".parse::<XsdAnyUri>()?);
|
/// question.set_instrument(uri!("https://example.com"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -322,12 +322,12 @@ pub trait ActivityExt<Kind>: AsActivity<Kind> {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{activity::Question, primitives::XsdAnyUri};
|
/// # use activitystreams_new::{activity::Question, uri};
|
||||||
/// # let mut question = Question::new();
|
/// # let mut question = Question::new();
|
||||||
///
|
///
|
||||||
/// question.set_many_instruments(vec![
|
/// question.set_many_instruments(vec![
|
||||||
/// "https://example.com/one".parse::<XsdAnyUri>()?,
|
/// uri!("https://example.com/one"),
|
||||||
/// "https://example.com/two".parse()?,
|
/// uri!("https://example.com/two"),
|
||||||
/// ]);
|
/// ]);
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
|
@ -349,12 +349,12 @@ pub trait ActivityExt<Kind>: AsActivity<Kind> {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{activity::Question, primitives::XsdAnyUri};
|
/// # use activitystreams_new::{activity::Question, uri};
|
||||||
/// # let mut question = Question::new();
|
/// # let mut question = Question::new();
|
||||||
///
|
///
|
||||||
/// question
|
/// question
|
||||||
/// .add_instrument("https://example.com/one".parse::<XsdAnyUri>()?)
|
/// .add_instrument(uri!("https://example.com/one"))
|
||||||
/// .add_instrument("https://example.com/two".parse::<XsdAnyUri>()?);
|
/// .add_instrument(uri!("https://example.com/two"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -393,9 +393,9 @@ pub trait ActivityExt<Kind>: AsActivity<Kind> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// # use activitystreams_new::{activity::Question, primitives::XsdAnyUri};
|
/// # use activitystreams_new::{activity::Question, uri};
|
||||||
/// # let mut question = Question::new();
|
/// # let mut question = Question::new();
|
||||||
/// # question.set_instrument("https://example.com".parse::<XsdAnyUri>()?);
|
/// # question.set_instrument(uri!("https://example.com"));
|
||||||
/// #
|
/// #
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
|
@ -435,17 +435,13 @@ pub trait ActorAndObjectRefExt: ActorAndObjectRef {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, activity::Create, uri};
|
||||||
/// # context,
|
|
||||||
/// # activity::Create,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut create = Create::new(context(), context());
|
/// # let mut create = Create::new(context(), context());
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
/// create.set_actor("https://example.com".parse::<XsdAnyUri>()?);
|
/// create.set_actor(uri!("https://example.com"));
|
||||||
///
|
///
|
||||||
/// assert!(create.actor_is(&"https://example.com".parse()?));
|
/// assert!(create.actor_is(&uri!("https://example.com")));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -460,14 +456,10 @@ pub trait ActorAndObjectRefExt: ActorAndObjectRef {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, activity::Create, uri};
|
||||||
/// # context,
|
|
||||||
/// # activity::Create,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut create = Create::new(context(), context());
|
/// # let mut create = Create::new(context(), context());
|
||||||
///
|
///
|
||||||
/// create.set_actor("https://example.com".parse::<XsdAnyUri>()?);
|
/// create.set_actor(uri!("https://example.com"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -486,16 +478,12 @@ pub trait ActorAndObjectRefExt: ActorAndObjectRef {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, activity::Create, uri};
|
||||||
/// # context,
|
|
||||||
/// # activity::Create,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut create = Create::new(context(), context());
|
/// # let mut create = Create::new(context(), context());
|
||||||
///
|
///
|
||||||
/// create.set_many_actors(vec![
|
/// create.set_many_actors(vec![
|
||||||
/// "https://example.com/one".parse::<XsdAnyUri>()?,
|
/// uri!("https://example.com/one"),
|
||||||
/// "https://example.com/two".parse()?,
|
/// uri!("https://example.com/two"),
|
||||||
/// ]);
|
/// ]);
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
|
@ -517,16 +505,12 @@ pub trait ActorAndObjectRefExt: ActorAndObjectRef {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, activity::Create, uri};
|
||||||
/// # context,
|
|
||||||
/// # activity::Create,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut create = Create::new(context(), context());
|
/// # let mut create = Create::new(context(), context());
|
||||||
///
|
///
|
||||||
/// create
|
/// create
|
||||||
/// .add_actor("https://example.com/one".parse::<XsdAnyUri>()?)
|
/// .add_actor(uri!("https://example.com/one"))
|
||||||
/// .add_actor("https://example.com/two".parse::<XsdAnyUri>()?);
|
/// .add_actor(uri!("https://example.com/two"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -557,17 +541,13 @@ pub trait ActorAndObjectRefExt: ActorAndObjectRef {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, activity::Create, uri};
|
||||||
/// # context,
|
|
||||||
/// # activity::Create,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut create = Create::new(context(), context());
|
/// # let mut create = Create::new(context(), context());
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
/// create.set_object("https://example.com".parse::<XsdAnyUri>()?);
|
/// create.set_object(uri!("https://example.com"));
|
||||||
///
|
///
|
||||||
/// assert!(create.object_is(&"https://example.com".parse()?));
|
/// assert!(create.object_is(&uri!("https://example.com")));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -582,14 +562,10 @@ pub trait ActorAndObjectRefExt: ActorAndObjectRef {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, activity::Create, uri};
|
||||||
/// # context,
|
|
||||||
/// # activity::Create,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut create = Create::new(context(), context());
|
/// # let mut create = Create::new(context(), context());
|
||||||
///
|
///
|
||||||
/// create.set_object("https://example.com".parse::<XsdAnyUri>()?);
|
/// create.set_object(uri!("https://example.com"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -608,16 +584,12 @@ pub trait ActorAndObjectRefExt: ActorAndObjectRef {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, activity::Create, uri};
|
||||||
/// # context,
|
|
||||||
/// # activity::Create,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut create = Create::new(context(), context());
|
/// # let mut create = Create::new(context(), context());
|
||||||
///
|
///
|
||||||
/// create.set_many_objects(vec![
|
/// create.set_many_objects(vec![
|
||||||
/// "https://example.com/one".parse::<XsdAnyUri>()?,
|
/// uri!("https://example.com/one"),
|
||||||
/// "https://example.com/two".parse()?,
|
/// uri!("https://example.com/two"),
|
||||||
/// ]);
|
/// ]);
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
|
@ -639,16 +611,12 @@ pub trait ActorAndObjectRefExt: ActorAndObjectRef {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, activity::Create, uri};
|
||||||
/// # context,
|
|
||||||
/// # activity::Create,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut create = Create::new(context(), context());
|
/// # let mut create = Create::new(context(), context());
|
||||||
///
|
///
|
||||||
/// create
|
/// create
|
||||||
/// .add_object("https://example.com/one".parse::<XsdAnyUri>()?)
|
/// .add_object(uri!("https://example.com/one"))
|
||||||
/// .add_object("https://example.com/two".parse::<XsdAnyUri>()?);
|
/// .add_object(uri!("https://example.com/two"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -687,14 +655,10 @@ pub trait TargetRefExt: TargetRef {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, activity::Invite, uri};
|
||||||
/// # context,
|
|
||||||
/// # activity::Invite,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut invite = Invite::new(context(), context(), context());
|
/// # let mut invite = Invite::new(context(), context(), context());
|
||||||
///
|
///
|
||||||
/// invite.set_target("https://example.com".parse::<XsdAnyUri>()?);
|
/// invite.set_target(uri!("https://example.com"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -713,16 +677,12 @@ pub trait TargetRefExt: TargetRef {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, activity::Invite, uri};
|
||||||
/// # context,
|
|
||||||
/// # activity::Invite,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut invite = Invite::new(context(), context(), context());
|
/// # let mut invite = Invite::new(context(), context(), context());
|
||||||
///
|
///
|
||||||
/// invite.set_many_targets(vec![
|
/// invite.set_many_targets(vec![
|
||||||
/// "https://example.com/one".parse::<XsdAnyUri>()?,
|
/// uri!("https://example.com/one"),
|
||||||
/// "https://example.com/two".parse()?,
|
/// uri!("https://example.com/two"),
|
||||||
/// ]);
|
/// ]);
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
|
@ -744,16 +704,12 @@ pub trait TargetRefExt: TargetRef {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, activity::Invite, uri};
|
||||||
/// # context,
|
|
||||||
/// # activity::Invite,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut invite = Invite::new(context(), context(), context());
|
/// # let mut invite = Invite::new(context(), context(), context());
|
||||||
///
|
///
|
||||||
/// invite
|
/// invite
|
||||||
/// .add_target("https://example.com/one".parse::<XsdAnyUri>()?)
|
/// .add_target(uri!("https://example.com/one"))
|
||||||
/// .add_target("https://example.com/two".parse::<XsdAnyUri>()?);
|
/// .add_target(uri!("https://example.com/two"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -792,14 +748,10 @@ pub trait OriginRefExt: OriginRef {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, activity::Arrive, uri};
|
||||||
/// # context,
|
|
||||||
/// # activity::Arrive,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut arrive = Arrive::new(context(), context());
|
/// # let mut arrive = Arrive::new(context(), context());
|
||||||
///
|
///
|
||||||
/// arrive.set_origin("https://example.com".parse::<XsdAnyUri>()?);
|
/// arrive.set_origin(uri!("https://example.com"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -818,16 +770,12 @@ pub trait OriginRefExt: OriginRef {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, activity::Arrive, uri};
|
||||||
/// # context,
|
|
||||||
/// # activity::Arrive,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut arrive = Arrive::new(context(), context());
|
/// # let mut arrive = Arrive::new(context(), context());
|
||||||
///
|
///
|
||||||
/// arrive.set_many_origins(vec![
|
/// arrive.set_many_origins(vec![
|
||||||
/// "https://example.com/one".parse::<XsdAnyUri>()?,
|
/// uri!("https://example.com/one"),
|
||||||
/// "https://example.com/two".parse()?,
|
/// uri!("https://example.com/two"),
|
||||||
/// ]);
|
/// ]);
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
|
@ -849,16 +797,12 @@ pub trait OriginRefExt: OriginRef {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, activity::Arrive, uri};
|
||||||
/// # context,
|
|
||||||
/// # activity::Arrive,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut arrive = Arrive::new(context(), context());
|
/// # let mut arrive = Arrive::new(context(), context());
|
||||||
///
|
///
|
||||||
/// arrive
|
/// arrive
|
||||||
/// .add_origin("https://example.com/one".parse::<XsdAnyUri>()?)
|
/// .add_origin(uri!("https://example.com/one"))
|
||||||
/// .add_origin("https://example.com/two".parse::<XsdAnyUri>()?);
|
/// .add_origin(uri!("https://example.com/two"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -899,14 +843,10 @@ pub trait OptTargetRefExt: OptTargetRef {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, activity::Announce, uri};
|
||||||
/// # context,
|
|
||||||
/// # activity::Announce,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut announce = Announce::new(context(), context());
|
/// # let mut announce = Announce::new(context(), context());
|
||||||
///
|
///
|
||||||
/// announce.set_target("https://example.com".parse::<XsdAnyUri>()?);
|
/// announce.set_target(uri!("https://example.com"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -925,16 +865,12 @@ pub trait OptTargetRefExt: OptTargetRef {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, activity::Announce, uri};
|
||||||
/// # context,
|
|
||||||
/// # activity::Announce,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut announce = Announce::new(context(), context());
|
/// # let mut announce = Announce::new(context(), context());
|
||||||
///
|
///
|
||||||
/// announce.set_many_targets(vec![
|
/// announce.set_many_targets(vec![
|
||||||
/// "https://example.com/one".parse::<XsdAnyUri>()?,
|
/// uri!("https://example.com/one"),
|
||||||
/// "https://example.com/two".parse()?,
|
/// uri!("https://example.com/two"),
|
||||||
/// ]);
|
/// ]);
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
|
@ -956,16 +892,12 @@ pub trait OptTargetRefExt: OptTargetRef {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, activity::Announce, uri};
|
||||||
/// # context,
|
|
||||||
/// # activity::Announce,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut announce = Announce::new(context(), context());
|
/// # let mut announce = Announce::new(context(), context());
|
||||||
///
|
///
|
||||||
/// announce
|
/// announce
|
||||||
/// .add_target("https://example.com/one".parse::<XsdAnyUri>()?)
|
/// .add_target(uri!("https://example.com/one"))
|
||||||
/// .add_target("https://example.com/two".parse::<XsdAnyUri>()?);
|
/// .add_target(uri!("https://example.com/two"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -992,7 +924,6 @@ pub trait OptTargetRefExt: OptTargetRef {
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{
|
||||||
/// # context,
|
/// # context,
|
||||||
/// # activity::Announce,
|
/// # activity::Announce,
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
/// # };
|
||||||
/// # let mut announce = Announce::new(context(), context());
|
/// # let mut announce = Announce::new(context(), context());
|
||||||
///
|
///
|
||||||
|
@ -1014,7 +945,6 @@ pub trait OptTargetRefExt: OptTargetRef {
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{
|
||||||
/// # context,
|
/// # context,
|
||||||
/// # activity::Announce,
|
/// # activity::Announce,
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
/// # };
|
||||||
/// # let mut announce = Announce::new(context(), context());
|
/// # let mut announce = Announce::new(context(), context());
|
||||||
/// # announce.set_target(context());
|
/// # announce.set_target(context());
|
||||||
|
@ -1059,14 +989,10 @@ pub trait OptOriginRefExt: OptOriginRef {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, activity::Delete, uri};
|
||||||
/// # context,
|
|
||||||
/// # activity::Delete,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut delete = Delete::new(context(), context());
|
/// # let mut delete = Delete::new(context(), context());
|
||||||
///
|
///
|
||||||
/// delete.set_origin("https://example.com".parse::<XsdAnyUri>()?);
|
/// delete.set_origin(uri!("https://example.com"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -1085,16 +1011,12 @@ pub trait OptOriginRefExt: OptOriginRef {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, activity::Delete, uri};
|
||||||
/// # context,
|
|
||||||
/// # activity::Delete,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut delete = Delete::new(context(), context());
|
/// # let mut delete = Delete::new(context(), context());
|
||||||
///
|
///
|
||||||
/// delete.set_many_origins(vec![
|
/// delete.set_many_origins(vec![
|
||||||
/// "https://example.com/one".parse::<XsdAnyUri>()?,
|
/// uri!("https://example.com/one"),
|
||||||
/// "https://example.com/two".parse()?,
|
/// uri!("https://example.com/two"),
|
||||||
/// ]);
|
/// ]);
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
|
@ -1116,16 +1038,12 @@ pub trait OptOriginRefExt: OptOriginRef {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, activity::Delete, uri};
|
||||||
/// # context,
|
|
||||||
/// # activity::Delete,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut delete = Delete::new(context(), context());
|
/// # let mut delete = Delete::new(context(), context());
|
||||||
///
|
///
|
||||||
/// delete
|
/// delete
|
||||||
/// .add_origin("https://example.com/one".parse::<XsdAnyUri>()?)
|
/// .add_origin(uri!("https://example.com/one"))
|
||||||
/// .add_origin("https://example.com/two".parse::<XsdAnyUri>()?);
|
/// .add_origin(uri!("https://example.com/two"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -1149,11 +1067,7 @@ pub trait OptOriginRefExt: OptOriginRef {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, activity::Delete};
|
||||||
/// # context,
|
|
||||||
/// # activity::Delete,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut delete = Delete::new(context(), context());
|
/// # let mut delete = Delete::new(context(), context());
|
||||||
///
|
///
|
||||||
/// if let Some(origin) = delete.take_origin() {
|
/// if let Some(origin) = delete.take_origin() {
|
||||||
|
@ -1171,11 +1085,7 @@ pub trait OptOriginRefExt: OptOriginRef {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, activity::Delete};
|
||||||
/// # context,
|
|
||||||
/// # activity::Delete,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut delete = Delete::new(context(), context());
|
/// # let mut delete = Delete::new(context(), context());
|
||||||
/// # delete.set_origin(context());
|
/// # delete.set_origin(context());
|
||||||
///
|
///
|
||||||
|
@ -1221,10 +1131,10 @@ pub trait QuestionExt: AsQuestion {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{activity::Question, primitives::XsdAnyUri};
|
/// # use activitystreams_new::{activity::Question, uri};
|
||||||
/// # let mut question = Question::new();
|
/// # let mut question = Question::new();
|
||||||
///
|
///
|
||||||
/// question.set_one_of("https://example.com".parse::<XsdAnyUri>()?);
|
/// question.set_one_of(uri!("https://example.com"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -1243,12 +1153,12 @@ pub trait QuestionExt: AsQuestion {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{activity::Question, primitives::XsdAnyUri};
|
/// # use activitystreams_new::{activity::Question, uri};
|
||||||
/// # let mut question = Question::new();
|
/// # let mut question = Question::new();
|
||||||
///
|
///
|
||||||
/// question.set_many_one_ofs(vec![
|
/// question.set_many_one_ofs(vec![
|
||||||
/// "https://example.com/one".parse::<XsdAnyUri>()?,
|
/// uri!("https://example.com/one"),
|
||||||
/// "https://example.com/two".parse()?,
|
/// uri!("https://example.com/two"),
|
||||||
/// ]);
|
/// ]);
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
|
@ -1270,12 +1180,12 @@ pub trait QuestionExt: AsQuestion {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{activity::Question, primitives::XsdAnyUri};
|
/// # use activitystreams_new::{activity::Question, uri};
|
||||||
/// # let mut question = Question::new();
|
/// # let mut question = Question::new();
|
||||||
///
|
///
|
||||||
/// question
|
/// question
|
||||||
/// .add_one_of("https://example.com/one".parse::<XsdAnyUri>()?)
|
/// .add_one_of(uri!("https://example.com/one"))
|
||||||
/// .add_one_of("https://example.com/two".parse::<XsdAnyUri>()?);
|
/// .add_one_of(uri!("https://example.com/two"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -1314,9 +1224,9 @@ pub trait QuestionExt: AsQuestion {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// # use activitystreams_new::{activity::Question, primitives::XsdAnyUri};
|
/// # use activitystreams_new::{activity::Question, uri};
|
||||||
/// # let mut question = Question::new();
|
/// # let mut question = Question::new();
|
||||||
/// # question.set_one_of("https://example.com".parse::<XsdAnyUri>()?);
|
/// # question.set_one_of(uri!("https://example.com"));
|
||||||
/// #
|
/// #
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
|
@ -1354,10 +1264,10 @@ pub trait QuestionExt: AsQuestion {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{activity::Question, primitives::XsdAnyUri};
|
/// # use activitystreams_new::{activity::Question, uri};
|
||||||
/// # let mut question = Question::new();
|
/// # let mut question = Question::new();
|
||||||
///
|
///
|
||||||
/// question.set_any_of("https://example.com".parse::<XsdAnyUri>()?);
|
/// question.set_any_of(uri!("https://example.com"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -1376,12 +1286,12 @@ pub trait QuestionExt: AsQuestion {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{activity::Question, primitives::XsdAnyUri};
|
/// # use activitystreams_new::{activity::Question, uri};
|
||||||
/// # let mut question = Question::new();
|
/// # let mut question = Question::new();
|
||||||
///
|
///
|
||||||
/// question.set_many_any_ofs(vec![
|
/// question.set_many_any_ofs(vec![
|
||||||
/// "https://example.com/one".parse::<XsdAnyUri>()?,
|
/// uri!("https://example.com/one"),
|
||||||
/// "https://example.com/two".parse()?,
|
/// uri!("https://example.com/two"),
|
||||||
/// ]);
|
/// ]);
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
|
@ -1403,12 +1313,12 @@ pub trait QuestionExt: AsQuestion {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{activity::Question, primitives::XsdAnyUri};
|
/// # use activitystreams_new::{activity::Question, uri};
|
||||||
/// # let mut question = Question::new();
|
/// # let mut question = Question::new();
|
||||||
///
|
///
|
||||||
/// question
|
/// question
|
||||||
/// .add_any_of("https://example.com/one".parse::<XsdAnyUri>()?)
|
/// .add_any_of(uri!("https://example.com/one"))
|
||||||
/// .add_any_of("https://example.com/two".parse::<XsdAnyUri>()?);
|
/// .add_any_of(uri!("https://example.com/two"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -1447,9 +1357,9 @@ pub trait QuestionExt: AsQuestion {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// # use activitystreams_new::{activity::Question, primitives::XsdAnyUri};
|
/// # use activitystreams_new::{activity::Question, uri};
|
||||||
/// # let mut question = Question::new();
|
/// # let mut question = Question::new();
|
||||||
/// # question.set_any_of("https://example.com".parse::<XsdAnyUri>()?);
|
/// # question.set_any_of(uri!("https://example.com"));
|
||||||
/// #
|
/// #
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
|
|
74
src/actor.rs
74
src/actor.rs
|
@ -5,18 +5,18 @@
|
||||||
//! use activitystreams_new::{
|
//! use activitystreams_new::{
|
||||||
//! actor::{ApActor, Person},
|
//! actor::{ApActor, Person},
|
||||||
//! prelude::*,
|
//! prelude::*,
|
||||||
//! primitives::XsdAnyUri,
|
//! uri,
|
||||||
//! };
|
//! };
|
||||||
//!
|
//!
|
||||||
//! let mut person = ApActor::new(
|
//! let mut person = ApActor::new(
|
||||||
//! "https://example.com/actor/inbox".parse()?,
|
//! uri!("https://example.com/actor/inbox"),
|
||||||
//! Person::new(),
|
//! Person::new(),
|
||||||
//! );
|
//! );
|
||||||
//!
|
//!
|
||||||
//! person
|
//! person
|
||||||
//! .set_outbox("https://example.com/actor/outbox".parse()?)
|
//! .set_outbox(uri!("https://example.com/actor/outbox"))
|
||||||
//! .set_following("https://example.com/actor/following".parse()?)
|
//! .set_following(uri!("https://example.com/actor/following"))
|
||||||
//! .set_followers("https://example.com/actor/followers".parse()?);
|
//! .set_followers(uri!("https://example.com/actor/followers"));
|
||||||
//! #
|
//! #
|
||||||
//! # Ok(())
|
//! # Ok(())
|
||||||
//! # }
|
//! # }
|
||||||
|
@ -78,11 +78,11 @@ pub trait ApActorExt<Inner>: AsApActor<Inner> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # 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());
|
/// # let mut person = ApActor::new(context(), Person::new());
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
/// person.set_inbox("https://example.com/inbox".parse()?);
|
/// person.set_inbox(uri!("https://example.com/inbox"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -111,11 +111,11 @@ pub trait ApActorExt<Inner>: AsApActor<Inner> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # 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());
|
/// # let mut person = ApActor::new(context(), Person::new());
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
/// person.set_outbox("https://example.com/outbox".parse()?);
|
/// person.set_outbox(uri!("https://example.com/outbox"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -143,9 +143,9 @@ pub trait ApActorExt<Inner>: AsApActor<Inner> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # 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());
|
/// # 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::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
/// assert!(person.outbox().is_some());
|
/// assert!(person.outbox().is_some());
|
||||||
|
@ -181,11 +181,11 @@ pub trait ApActorExt<Inner>: AsApActor<Inner> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # 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());
|
/// # let mut person = ApActor::new(context(), Person::new());
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
/// person.set_following("https://example.com/following".parse()?);
|
/// person.set_following(uri!("https://example.com/following"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -213,9 +213,9 @@ pub trait ApActorExt<Inner>: AsApActor<Inner> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # 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());
|
/// # 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::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
/// assert!(person.following().is_some());
|
/// assert!(person.following().is_some());
|
||||||
|
@ -251,11 +251,11 @@ pub trait ApActorExt<Inner>: AsApActor<Inner> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # 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());
|
/// # let mut person = ApActor::new(context(), Person::new());
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
/// person.set_followers("https://example.com/followers".parse()?);
|
/// person.set_followers(uri!("https://example.com/followers"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -283,9 +283,9 @@ pub trait ApActorExt<Inner>: AsApActor<Inner> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # 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());
|
/// # 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::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
/// assert!(person.followers().is_some());
|
/// assert!(person.followers().is_some());
|
||||||
|
@ -321,11 +321,11 @@ pub trait ApActorExt<Inner>: AsApActor<Inner> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # 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());
|
/// # let mut person = ApActor::new(context(), Person::new());
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
/// person.set_streams("https://example.com/liked".parse()?);
|
/// person.set_streams(uri!("https://example.com/liked"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -353,9 +353,9 @@ pub trait ApActorExt<Inner>: AsApActor<Inner> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # 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());
|
/// # 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::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
/// assert!(person.liked().is_some());
|
/// assert!(person.liked().is_some());
|
||||||
|
@ -391,11 +391,11 @@ pub trait ApActorExt<Inner>: AsApActor<Inner> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # 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());
|
/// # let mut person = ApActor::new(context(), Person::new());
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
/// person.set_streams("https://example.com/streams".parse()?);
|
/// person.set_streams(uri!("https://example.com/streams"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -408,13 +408,13 @@ pub trait ApActorExt<Inner>: AsApActor<Inner> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # 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());
|
/// # let mut person = ApActor::new(context(), Person::new());
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
/// person.set_many_streams(vec![
|
/// person.set_many_streams(vec![
|
||||||
/// "https://example.com/streams1".parse()?,
|
/// uri!("https://example.com/streams1"),
|
||||||
/// "https://example.com/streams2".parse()?
|
/// uri!("https://example.com/streams2"),
|
||||||
/// ]);
|
/// ]);
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
|
@ -432,13 +432,13 @@ pub trait ApActorExt<Inner>: AsApActor<Inner> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # 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());
|
/// # let mut person = ApActor::new(context(), Person::new());
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
/// person
|
/// person
|
||||||
/// .add_streams("https://example.com/streams1".parse()?)
|
/// .add_streams(uri!("https://example.com/streams1"))
|
||||||
/// .add_streams("https://example.com/streams2".parse()?);
|
/// .add_streams(uri!("https://example.com/streams2"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -473,9 +473,9 @@ pub trait ApActorExt<Inner>: AsApActor<Inner> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # 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());
|
/// # 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::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
/// assert!(person.streams().is_some());
|
/// assert!(person.streams().is_some());
|
||||||
|
@ -584,12 +584,12 @@ pub trait ApActorExt<Inner>: AsApActor<Inner> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # 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());
|
/// # let mut person = ApActor::new(context(), Person::new());
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
/// person.set_endpoints(Endpoints {
|
/// person.set_endpoints(Endpoints {
|
||||||
/// shared_inbox: Some("https://example.com/inbox".parse()?),
|
/// shared_inbox: Some(uri!("https://example.com/inbox")),
|
||||||
/// ..Default::default()
|
/// ..Default::default()
|
||||||
/// });
|
/// });
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
|
@ -865,10 +865,10 @@ impl<Inner> ApActor<Inner> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::actor::{ApActor, Person};
|
/// use activitystreams_new::{actor::{ApActor, Person}, uri};
|
||||||
///
|
///
|
||||||
/// let actor = ApActor::new(
|
/// let actor = ApActor::new(
|
||||||
/// "https://example.com/inbox".parse()?,
|
/// uri!("https://example.com/inbox"),
|
||||||
/// Person::new(),
|
/// Person::new(),
|
||||||
/// );
|
/// );
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
|
|
127
src/base.rs
127
src/base.rs
|
@ -8,11 +8,12 @@
|
||||||
//! object::Video,
|
//! object::Video,
|
||||||
//! prelude::*,
|
//! prelude::*,
|
||||||
//! security,
|
//! security,
|
||||||
|
//! uri,
|
||||||
//! };
|
//! };
|
||||||
//! let mut video = Video::new();
|
//! let mut video = Video::new();
|
||||||
//!
|
//!
|
||||||
//! video
|
//! video
|
||||||
//! .set_id("https://example.com".parse()?)
|
//! .set_id(uri!("https://example.com"))
|
||||||
//! .set_context(context())
|
//! .set_context(context())
|
||||||
//! .add_context(security())
|
//! .add_context(security())
|
||||||
//! .set_name("Hello");
|
//! .set_name("Hello");
|
||||||
|
@ -266,11 +267,11 @@ pub trait BaseExt<Kind>: AsBase<Kind> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # 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"}"#)?;
|
/// 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(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -287,9 +288,9 @@ pub trait BaseExt<Kind>: AsBase<Kind> {
|
||||||
/// # use activitystreams_new::object::Video;
|
/// # use activitystreams_new::object::Video;
|
||||||
/// # let mut video = Video::new();
|
/// # 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(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -648,10 +649,10 @@ pub trait BaseExt<Kind>: AsBase<Kind> {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
/// # use activitystreams_new::{object::Video, uri};
|
||||||
/// # let mut video = Video::new();
|
/// # let mut video = Video::new();
|
||||||
///
|
///
|
||||||
/// video.set_preview("https://example.com".parse::<XsdAnyUri>()?);
|
/// video.set_preview(uri!("https://example.com"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -670,12 +671,12 @@ pub trait BaseExt<Kind>: AsBase<Kind> {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
/// # use activitystreams_new::{object::Video, uri};
|
||||||
/// # let mut video = Video::new();
|
/// # let mut video = Video::new();
|
||||||
///
|
///
|
||||||
/// video.set_many_previews(vec![
|
/// video.set_many_previews(vec![
|
||||||
/// "https://example.com/one".parse::<XsdAnyUri>()?,
|
/// uri!("https://example.com/one"),
|
||||||
/// "https://example.com/two".parse()?,
|
/// uri!("https://example.com/two"),
|
||||||
/// ]);
|
/// ]);
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
|
@ -697,12 +698,12 @@ pub trait BaseExt<Kind>: AsBase<Kind> {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
/// # use activitystreams_new::{object::Video, uri};
|
||||||
/// # let mut video = Video::new();
|
/// # let mut video = Video::new();
|
||||||
///
|
///
|
||||||
/// video
|
/// video
|
||||||
/// .add_preview("https://example.com/one".parse::<XsdAnyUri>()?)
|
/// .add_preview(uri!("https://example.com/one"))
|
||||||
/// .add_preview("https://example.com/two".parse::<XsdAnyUri>()?);
|
/// .add_preview(uri!("https://example.com/two"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -741,9 +742,9 @@ pub trait BaseExt<Kind>: AsBase<Kind> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
/// # use activitystreams_new::{object::Video, uri};
|
||||||
/// # let mut video = Video::new();
|
/// # let mut video = Video::new();
|
||||||
/// # video.set_preview("https://example.com".parse::<XsdAnyUri>()?);
|
/// # video.set_preview(uri!("https://example.com"));
|
||||||
/// #
|
/// #
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
|
@ -1040,9 +1041,9 @@ impl AnyBase {
|
||||||
/// Check if this object is an XsdAnyUri
|
/// Check if this object is an XsdAnyUri
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use activitystreams_new::base::AnyBase;
|
/// # use activitystreams_new::{base::AnyBase, uri};
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # 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());
|
/// assert!(any_base.is_xsd_any_uri());
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
|
@ -1092,11 +1093,9 @@ impl AnyBase {
|
||||||
/// #### Get the ID from the nested video
|
/// #### Get the ID from the nested video
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{object::Video, base::AnyBase, prelude::*, uri};
|
||||||
/// # object::Video, base::AnyBase, prelude::*, primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut video = Video::new();
|
/// # let mut video = Video::new();
|
||||||
/// let id = "https://example.com".parse::<XsdAnyUri>()?;
|
/// let id = uri!("https://example.com");
|
||||||
///
|
///
|
||||||
/// video.set_id(id.clone());
|
/// video.set_id(id.clone());
|
||||||
///
|
///
|
||||||
|
@ -1109,10 +1108,8 @@ impl AnyBase {
|
||||||
/// #### Get the ID from the AnyBase
|
/// #### Get the ID from the AnyBase
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{base::AnyBase, prelude::*, uri};
|
||||||
/// # base::AnyBase, prelude::*, primitives::XsdAnyUri
|
/// let id = uri!("https://example.com");
|
||||||
/// # };
|
|
||||||
/// let id = "https://example.com".parse::<XsdAnyUri>()?;
|
|
||||||
///
|
///
|
||||||
/// let any_base = AnyBase::from_xsd_any_uri(id.clone());
|
/// let any_base = AnyBase::from_xsd_any_uri(id.clone());
|
||||||
/// assert!(any_base.id().unwrap() == &id);
|
/// assert!(any_base.id().unwrap() == &id);
|
||||||
|
@ -1129,15 +1126,15 @@ impl AnyBase {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{
|
||||||
/// # object::{kind::VideoType, Video}, base::AnyBase, prelude::*,
|
/// # object::{kind::VideoType, Video}, base::AnyBase, prelude::*, uri
|
||||||
/// # };
|
/// # };
|
||||||
/// # let mut video = Video::new();
|
/// # 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)?;
|
/// 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(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -1223,9 +1220,9 @@ impl AnyBase {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # 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());
|
/// assert!(any_base.as_xsd_any_uri().is_some());
|
||||||
/// #
|
/// #
|
||||||
|
@ -1271,9 +1268,9 @@ impl AnyBase {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # 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());
|
/// assert!(any_base.take_xsd_any_uri().is_some());
|
||||||
/// #
|
/// #
|
||||||
|
@ -1319,11 +1316,11 @@ impl AnyBase {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # 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());
|
/// 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());
|
/// assert!(any_base.take_xsd_any_uri().is_some());
|
||||||
/// #
|
/// #
|
||||||
|
@ -1338,19 +1335,22 @@ impl AnyBase {
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # 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());
|
/// assert!(any_base.take_xsd_string().is_some());
|
||||||
/// #
|
/// #
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn set_xsd_string(&mut self, xsd_string: String) {
|
pub fn set_xsd_string<T>(&mut self, xsd_string: T)
|
||||||
self.0 = Either::Right(xsd_string);
|
where
|
||||||
|
T: Into<String>,
|
||||||
|
{
|
||||||
|
self.0 = Either::Right(xsd_string.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Replace the object with the provided `Base<serde_json::Value>`
|
/// Replace the object with the provided `Base<serde_json::Value>`
|
||||||
|
@ -1377,8 +1377,8 @@ impl AnyBase {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # 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"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -1444,13 +1444,16 @@ impl OneOrMany<AnyBase> {
|
||||||
/// Get the ID from a single object if there is only one object
|
/// Get the ID from a single object if there is only one object
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```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::<String>::new();
|
/// # let mut base = Base::<String>::new();
|
||||||
/// # let id: XsdAnyUri = "https://example.com".parse().unwrap();
|
/// # let id = uri!("https://example.com");
|
||||||
/// # base.id = Some(id.clone());
|
/// # 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));
|
/// assert!(base.as_single_id() == Some(&id));
|
||||||
|
/// # Ok(())
|
||||||
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn as_single_id(&self) -> Option<&XsdAnyUri> {
|
pub fn as_single_id(&self) -> Option<&XsdAnyUri> {
|
||||||
self.as_one().and_then(|one| one.id())
|
self.as_one().and_then(|one| one.id())
|
||||||
|
@ -1459,13 +1462,16 @@ impl OneOrMany<AnyBase> {
|
||||||
/// Check if there's only one ID, and if it equals `id`
|
/// Check if there's only one ID, and if it equals `id`
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```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::<String>::new();
|
/// # let mut base = Base::<String>::new();
|
||||||
/// # let id: XsdAnyUri = "https://example.com".parse().unwrap();
|
/// # let id = uri!("https://example.com");
|
||||||
/// # base.id = Some(id.clone());
|
/// # 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));
|
/// assert!(base.is_single_id(&id));
|
||||||
|
/// # Ok(())
|
||||||
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn is_single_id(&self, id: &XsdAnyUri) -> bool {
|
pub fn is_single_id(&self, id: &XsdAnyUri) -> bool {
|
||||||
self.as_single_id() == Some(id)
|
self.as_single_id() == Some(id)
|
||||||
|
@ -1474,12 +1480,15 @@ impl OneOrMany<AnyBase> {
|
||||||
/// Get the kind of a single object if there is only one object
|
/// Get the kind of a single object if there is only one object
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// # use activitystreams_new::{base::Base, primitives::OneOrMany};
|
/// # use activitystreams_new::{base::Base, primitives::OneOrMany};
|
||||||
/// # let mut base = Base::new();
|
/// # let mut base = Base::new();
|
||||||
/// # base.kind = Some(String::from("Person"));
|
/// # 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"));
|
/// assert!(base.as_single_kind_str() == Some("Person"));
|
||||||
|
/// # Ok(())
|
||||||
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn as_single_kind(&self) -> Option<&serde_json::Value> {
|
pub fn as_single_kind(&self) -> Option<&serde_json::Value> {
|
||||||
self.as_one().and_then(|one| one.kind())
|
self.as_one().and_then(|one| one.kind())
|
||||||
|
@ -1489,12 +1498,15 @@ impl OneOrMany<AnyBase> {
|
||||||
///
|
///
|
||||||
/// This returns None if the kind is not present, or not a String
|
/// 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};
|
/// # use activitystreams_new::{base::Base, primitives::OneOrMany};
|
||||||
/// # let mut base = Base::new();
|
/// # let mut base = Base::new();
|
||||||
/// # base.kind = Some(String::from("Person"));
|
/// # 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"));
|
/// assert!(base.as_single_kind_str() == Some("Person"));
|
||||||
|
/// # Ok(())
|
||||||
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn as_single_kind_str(&self) -> Option<&str> {
|
pub fn as_single_kind_str(&self) -> Option<&str> {
|
||||||
self.as_one().and_then(|one| one.kind_str())
|
self.as_one().and_then(|one| one.kind_str())
|
||||||
|
@ -1505,12 +1517,15 @@ impl OneOrMany<AnyBase> {
|
||||||
/// This returns False if the kind is not present, or not a String
|
/// 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};
|
/// # use activitystreams_new::{base::Base, primitives::OneOrMany};
|
||||||
/// # let mut base = Base::new();
|
/// # let mut base = Base::new();
|
||||||
/// # base.kind = Some(String::from("Person"));
|
/// # 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"));
|
/// assert!(base.is_single_kind("Person"));
|
||||||
|
/// # Ok(())
|
||||||
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn is_single_kind(&self, kind: &str) -> bool {
|
pub fn is_single_kind(&self, kind: &str) -> bool {
|
||||||
self.as_single_kind_str() == Some(kind)
|
self.as_single_kind_str() == Some(kind)
|
||||||
|
@ -1520,9 +1535,9 @@ impl OneOrMany<AnyBase> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # 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());
|
/// assert!(one.as_single_xsd_any_uri().is_some());
|
||||||
/// #
|
/// #
|
||||||
|
@ -1564,9 +1579,9 @@ impl OneOrMany<AnyBase> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # 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());
|
/// assert!(one.single_xsd_any_uri().is_some());
|
||||||
/// #
|
/// #
|
||||||
|
@ -1608,9 +1623,9 @@ impl OneOrMany<AnyBase> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # 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(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
|
@ -6,19 +6,19 @@
|
||||||
//! collection::OrderedCollection,
|
//! collection::OrderedCollection,
|
||||||
//! context,
|
//! context,
|
||||||
//! prelude::*,
|
//! prelude::*,
|
||||||
//! primitives::XsdAnyUri,
|
//! uri,
|
||||||
//! };
|
//! };
|
||||||
//!
|
//!
|
||||||
//! let mut collection = OrderedCollection::new(vec![
|
//! let mut collection = OrderedCollection::new(vec![
|
||||||
//! "https://example.com/notes/1234".parse::<XsdAnyUri>()?.into(),
|
//! uri!("https://example.com/notes/1234").into(),
|
||||||
//! ]);
|
//! ]);
|
||||||
//!
|
//!
|
||||||
//! collection
|
//! collection
|
||||||
//! .set_total_items(1)
|
//! .set_total_items(1)
|
||||||
//! .set_current("https://example.com/notes/1234".parse::<XsdAnyUri>()?)
|
//! .set_current(uri!("https://example.com/notes/1234"))
|
||||||
//! .set_first("https://example.com/notes/1234".parse::<XsdAnyUri>()?)
|
//! .set_first(uri!("https://example.com/notes/1234"))
|
||||||
//! .set_last("https://example.com/notes/1234".parse::<XsdAnyUri>()?)
|
//! .set_last(uri!("https://example.com/notes/1234"))
|
||||||
//! .set_id("https://example.com/collections/1234".parse()?)
|
//! .set_id(uri!("https://example.com/collections/1234"))
|
||||||
//! .set_context(context());
|
//! .set_context(context());
|
||||||
//! # Ok(())
|
//! # Ok(())
|
||||||
//! # }
|
//! # }
|
||||||
|
@ -101,14 +101,10 @@ pub trait CollectionExt<Kind>: AsCollection<Kind> {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::UnorderedCollection, uri};
|
||||||
/// # context,
|
|
||||||
/// # collection::UnorderedCollection,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
||||||
///
|
///
|
||||||
/// collection.set_items("https://example.com".parse::<XsdAnyUri>()?);
|
/// collection.set_items(uri!("https://example.com"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -127,16 +123,12 @@ pub trait CollectionExt<Kind>: AsCollection<Kind> {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::UnorderedCollection, uri};
|
||||||
/// # context,
|
|
||||||
/// # collection::UnorderedCollection,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
||||||
///
|
///
|
||||||
/// collection.set_many_items(vec![
|
/// collection.set_many_items(vec![
|
||||||
/// "https://example.com/one".parse::<XsdAnyUri>()?,
|
/// uri!("https://example.com/one"),
|
||||||
/// "https://example.com/two".parse()?,
|
/// uri!("https://example.com/two"),
|
||||||
/// ]);
|
/// ]);
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
|
@ -158,16 +150,12 @@ pub trait CollectionExt<Kind>: AsCollection<Kind> {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::UnorderedCollection, uri};
|
||||||
/// # context,
|
|
||||||
/// # collection::UnorderedCollection,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
||||||
///
|
///
|
||||||
/// collection
|
/// collection
|
||||||
/// .add_items("https://example.com/one".parse::<XsdAnyUri>()?)
|
/// .add_items(uri!("https://example.com/one"))
|
||||||
/// .add_items("https://example.com/two".parse::<XsdAnyUri>()?);
|
/// .add_items(uri!("https://example.com/two"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -182,11 +170,7 @@ pub trait CollectionExt<Kind>: AsCollection<Kind> {
|
||||||
/// Fetch the total_items of the current object
|
/// Fetch the total_items of the current object
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::UnorderedCollection};
|
||||||
/// # context,
|
|
||||||
/// # collection::UnorderedCollection,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
|
@ -206,11 +190,7 @@ pub trait CollectionExt<Kind>: AsCollection<Kind> {
|
||||||
/// This overwrites the contents of total_items
|
/// This overwrites the contents of total_items
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::UnorderedCollection};
|
||||||
/// # context,
|
|
||||||
/// # collection::UnorderedCollection,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
|
@ -227,11 +207,7 @@ pub trait CollectionExt<Kind>: AsCollection<Kind> {
|
||||||
/// Take the total_items of the current object, leaving nothing
|
/// Take the total_items of the current object, leaving nothing
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::UnorderedCollection};
|
||||||
/// # context,
|
|
||||||
/// # collection::UnorderedCollection,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
|
@ -246,11 +222,7 @@ pub trait CollectionExt<Kind>: AsCollection<Kind> {
|
||||||
/// Delete the total_items from the current object
|
/// Delete the total_items from the current object
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::UnorderedCollection};
|
||||||
/// # context,
|
|
||||||
/// # collection::UnorderedCollection,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
||||||
/// # collection.set_total_items(5);
|
/// # collection.set_total_items(5);
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
|
@ -267,11 +239,7 @@ pub trait CollectionExt<Kind>: AsCollection<Kind> {
|
||||||
/// Fetch the current field for the current object
|
/// Fetch the current field for the current object
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::UnorderedCollection};
|
||||||
/// # context,
|
|
||||||
/// # collection::UnorderedCollection,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
||||||
/// #
|
/// #
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
|
@ -293,16 +261,12 @@ pub trait CollectionExt<Kind>: AsCollection<Kind> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::UnorderedCollection, uri};
|
||||||
/// # context,
|
|
||||||
/// # collection::UnorderedCollection,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
||||||
/// #
|
/// #
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
/// collection.set_current("https://example.com".parse::<XsdAnyUri>()?);
|
/// collection.set_current(uri!("https://example.com"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -317,11 +281,7 @@ pub trait CollectionExt<Kind>: AsCollection<Kind> {
|
||||||
/// Take the current field from the current object, leaving nothing
|
/// Take the current field from the current object, leaving nothing
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::UnorderedCollection};
|
||||||
/// # context,
|
|
||||||
/// # collection::UnorderedCollection,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
||||||
/// #
|
/// #
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
|
@ -337,11 +297,7 @@ pub trait CollectionExt<Kind>: AsCollection<Kind> {
|
||||||
/// Delete the current field from the current object
|
/// Delete the current field from the current object
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::UnorderedCollection};
|
||||||
/// # context,
|
|
||||||
/// # collection::UnorderedCollection,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
||||||
/// # collection.set_current(context());
|
/// # collection.set_current(context());
|
||||||
/// #
|
/// #
|
||||||
|
@ -359,11 +315,7 @@ pub trait CollectionExt<Kind>: AsCollection<Kind> {
|
||||||
/// Fetch the first field for the current object
|
/// Fetch the first field for the current object
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::UnorderedCollection};
|
||||||
/// # context,
|
|
||||||
/// # collection::UnorderedCollection,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
||||||
/// #
|
/// #
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
|
@ -385,16 +337,12 @@ pub trait CollectionExt<Kind>: AsCollection<Kind> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::UnorderedCollection};
|
||||||
/// # context,
|
|
||||||
/// # collection::UnorderedCollection,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
||||||
/// #
|
/// #
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::{prelude::*, uri};
|
||||||
///
|
///
|
||||||
/// collection.set_first("https://example.com".parse::<XsdAnyUri>()?);
|
/// collection.set_first(uri!("https://example.com"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -409,11 +357,7 @@ pub trait CollectionExt<Kind>: AsCollection<Kind> {
|
||||||
/// Take the first field from the current object, leaving nothing
|
/// Take the first field from the current object, leaving nothing
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::UnorderedCollection};
|
||||||
/// # context,
|
|
||||||
/// # collection::UnorderedCollection,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
||||||
/// #
|
/// #
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
|
@ -429,11 +373,7 @@ pub trait CollectionExt<Kind>: AsCollection<Kind> {
|
||||||
/// Delete the first field from the current object
|
/// Delete the first field from the current object
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::UnorderedCollection};
|
||||||
/// # context,
|
|
||||||
/// # collection::UnorderedCollection,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
||||||
/// # collection.set_first(context());
|
/// # collection.set_first(context());
|
||||||
/// #
|
/// #
|
||||||
|
@ -451,11 +391,7 @@ pub trait CollectionExt<Kind>: AsCollection<Kind> {
|
||||||
/// Fetch the last field for the current object
|
/// Fetch the last field for the current object
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::UnorderedCollection};
|
||||||
/// # context,
|
|
||||||
/// # collection::UnorderedCollection,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
||||||
/// #
|
/// #
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
|
@ -477,16 +413,12 @@ pub trait CollectionExt<Kind>: AsCollection<Kind> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::UnorderedCollection};
|
||||||
/// # context,
|
|
||||||
/// # collection::UnorderedCollection,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
||||||
/// #
|
/// #
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::{prelude::*, uri};
|
||||||
///
|
///
|
||||||
/// collection.set_last("https://example.com".parse::<XsdAnyUri>()?);
|
/// collection.set_last(uri!("https://example.com"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -501,11 +433,7 @@ pub trait CollectionExt<Kind>: AsCollection<Kind> {
|
||||||
/// Take the last field from the current object, leaving nothing
|
/// Take the last field from the current object, leaving nothing
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::UnorderedCollection};
|
||||||
/// # context,
|
|
||||||
/// # collection::UnorderedCollection,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
||||||
/// #
|
/// #
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
|
@ -521,11 +449,7 @@ pub trait CollectionExt<Kind>: AsCollection<Kind> {
|
||||||
/// Delete the last field from the current object
|
/// Delete the last field from the current object
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::UnorderedCollection};
|
||||||
/// # context,
|
|
||||||
/// # collection::UnorderedCollection,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
/// # let mut collection = UnorderedCollection::new(vec![context().into()]);
|
||||||
/// # collection.set_last(context());
|
/// # collection.set_last(context());
|
||||||
/// #
|
/// #
|
||||||
|
@ -551,11 +475,7 @@ pub trait CollectionPageExt<Kind>: AsCollectionPage<Kind> {
|
||||||
/// Fetch the part_of field for the current object
|
/// Fetch the part_of field for the current object
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::UnorderedCollectionPage};
|
||||||
/// # context,
|
|
||||||
/// # collection::UnorderedCollectionPage,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]);
|
/// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]);
|
||||||
/// #
|
/// #
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
|
@ -577,16 +497,12 @@ pub trait CollectionPageExt<Kind>: AsCollectionPage<Kind> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::UnorderedCollectionPage};
|
||||||
/// # context,
|
|
||||||
/// # collection::UnorderedCollectionPage,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]);
|
/// # 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::<XsdAnyUri>()?);
|
/// collection.set_part_of(uri!("https://example.com"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -601,11 +517,7 @@ pub trait CollectionPageExt<Kind>: AsCollectionPage<Kind> {
|
||||||
/// Take the part_of field from the current object, leaving nothing
|
/// Take the part_of field from the current object, leaving nothing
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::UnorderedCollectionPage};
|
||||||
/// # context,
|
|
||||||
/// # collection::UnorderedCollectionPage,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]);
|
/// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]);
|
||||||
/// #
|
/// #
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
|
@ -621,11 +533,7 @@ pub trait CollectionPageExt<Kind>: AsCollectionPage<Kind> {
|
||||||
/// Delete the part_of field from the current object
|
/// Delete the part_of field from the current object
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::UnorderedCollectionPage};
|
||||||
/// # context,
|
|
||||||
/// # collection::UnorderedCollectionPage,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]);
|
/// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]);
|
||||||
/// # collection.set_part_of(context());
|
/// # collection.set_part_of(context());
|
||||||
/// #
|
/// #
|
||||||
|
@ -643,11 +551,7 @@ pub trait CollectionPageExt<Kind>: AsCollectionPage<Kind> {
|
||||||
/// Fetch the next field for the current object
|
/// Fetch the next field for the current object
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::UnorderedCollectionPage};
|
||||||
/// # context,
|
|
||||||
/// # collection::UnorderedCollectionPage,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]);
|
/// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]);
|
||||||
/// #
|
/// #
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
|
@ -669,16 +573,12 @@ pub trait CollectionPageExt<Kind>: AsCollectionPage<Kind> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::UnorderedCollectionPage};
|
||||||
/// # context,
|
|
||||||
/// # collection::UnorderedCollectionPage,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]);
|
/// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]);
|
||||||
/// #
|
/// #
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::{prelude::*, uri};
|
||||||
///
|
///
|
||||||
/// collection.set_next("https://example.com".parse::<XsdAnyUri>()?);
|
/// collection.set_next(uri!("https://example.com"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -693,11 +593,7 @@ pub trait CollectionPageExt<Kind>: AsCollectionPage<Kind> {
|
||||||
/// Take the next field from the current object, leaving nothing
|
/// Take the next field from the current object, leaving nothing
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::UnorderedCollectionPage};
|
||||||
/// # context,
|
|
||||||
/// # collection::UnorderedCollectionPage,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]);
|
/// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]);
|
||||||
/// #
|
/// #
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
|
@ -713,11 +609,7 @@ pub trait CollectionPageExt<Kind>: AsCollectionPage<Kind> {
|
||||||
/// Delete the next field from the current object
|
/// Delete the next field from the current object
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::UnorderedCollectionPage};
|
||||||
/// # context,
|
|
||||||
/// # collection::UnorderedCollectionPage,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]);
|
/// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]);
|
||||||
/// # collection.set_next(context());
|
/// # collection.set_next(context());
|
||||||
/// #
|
/// #
|
||||||
|
@ -735,11 +627,7 @@ pub trait CollectionPageExt<Kind>: AsCollectionPage<Kind> {
|
||||||
/// Fetch the prev field for the current object
|
/// Fetch the prev field for the current object
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::UnorderedCollectionPage};
|
||||||
/// # context,
|
|
||||||
/// # collection::UnorderedCollectionPage,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]);
|
/// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]);
|
||||||
/// #
|
/// #
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
|
@ -761,16 +649,12 @@ pub trait CollectionPageExt<Kind>: AsCollectionPage<Kind> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::UnorderedCollectionPage};
|
||||||
/// # context,
|
|
||||||
/// # collection::UnorderedCollectionPage,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]);
|
/// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]);
|
||||||
/// #
|
/// #
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::{prelude::*, uri};
|
||||||
///
|
///
|
||||||
/// collection.set_prev("https://example.com".parse::<XsdAnyUri>()?);
|
/// collection.set_prev(uri!("https://example.com"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -785,11 +669,7 @@ pub trait CollectionPageExt<Kind>: AsCollectionPage<Kind> {
|
||||||
/// Take the prev field from the current object, leaving nothing
|
/// Take the prev field from the current object, leaving nothing
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::UnorderedCollectionPage};
|
||||||
/// # context,
|
|
||||||
/// # collection::UnorderedCollectionPage,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]);
|
/// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]);
|
||||||
/// #
|
/// #
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
|
@ -805,11 +685,7 @@ pub trait CollectionPageExt<Kind>: AsCollectionPage<Kind> {
|
||||||
/// Delete the prev field from the current object
|
/// Delete the prev field from the current object
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::UnorderedCollectionPage};
|
||||||
/// # context,
|
|
||||||
/// # collection::UnorderedCollectionPage,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]);
|
/// # let mut collection = UnorderedCollectionPage::new(vec![context().into()]);
|
||||||
/// # collection.set_prev(context());
|
/// # collection.set_prev(context());
|
||||||
/// #
|
/// #
|
||||||
|
@ -829,11 +705,7 @@ pub trait OrderedCollectionPageExt: AsOrderedCollectionPage {
|
||||||
/// Fetch the start_index of the current object
|
/// Fetch the start_index of the current object
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::OrderedCollectionPage};
|
||||||
/// # context,
|
|
||||||
/// # collection::OrderedCollectionPage,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = OrderedCollectionPage::new(vec![context().into()]);
|
/// # let mut collection = OrderedCollectionPage::new(vec![context().into()]);
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
|
@ -850,11 +722,7 @@ pub trait OrderedCollectionPageExt: AsOrderedCollectionPage {
|
||||||
/// This overwrites the contents of start_index
|
/// This overwrites the contents of start_index
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::OrderedCollectionPage};
|
||||||
/// # context,
|
|
||||||
/// # collection::OrderedCollectionPage,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = OrderedCollectionPage::new(vec![context().into()]);
|
/// # let mut collection = OrderedCollectionPage::new(vec![context().into()]);
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
|
@ -871,11 +739,7 @@ pub trait OrderedCollectionPageExt: AsOrderedCollectionPage {
|
||||||
/// Take the start_index of the current object, leaving nothing
|
/// Take the start_index of the current object, leaving nothing
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::OrderedCollectionPage};
|
||||||
/// # context,
|
|
||||||
/// # collection::OrderedCollectionPage,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = OrderedCollectionPage::new(vec![context().into()]);
|
/// # let mut collection = OrderedCollectionPage::new(vec![context().into()]);
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
|
@ -890,11 +754,7 @@ pub trait OrderedCollectionPageExt: AsOrderedCollectionPage {
|
||||||
/// Delete the start_index from the current object
|
/// Delete the start_index from the current object
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use activitystreams_new::{
|
/// # use activitystreams_new::{context, collection::OrderedCollectionPage};
|
||||||
/// # context,
|
|
||||||
/// # collection::OrderedCollectionPage,
|
|
||||||
/// # primitives::XsdAnyUri
|
|
||||||
/// # };
|
|
||||||
/// # let mut collection = OrderedCollectionPage::new(vec![context().into()]);
|
/// # let mut collection = OrderedCollectionPage::new(vec![context().into()]);
|
||||||
/// # collection.set_start_index(5);
|
/// # collection.set_start_index(5);
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
|
|
64
src/lib.rs
64
src/lib.rs
|
@ -164,14 +164,14 @@
|
||||||
//! bound the function like so:
|
//! bound the function like so:
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! use activitystreams_new::{base::BaseExt, context, markers::Activity};
|
//! use activitystreams_new::{base::BaseExt, context, markers::Activity, uri};
|
||||||
//!
|
//!
|
||||||
//! fn manipulator<T, Kind>(mut activity: T) -> Result<(), anyhow::Error>
|
//! fn manipulator<T, Kind>(mut activity: T) -> Result<(), anyhow::Error>
|
||||||
//! where
|
//! where
|
||||||
//! T: Activity + BaseExt<Kind>,
|
//! T: Activity + BaseExt<Kind>,
|
||||||
//! {
|
//! {
|
||||||
//! activity
|
//! activity
|
||||||
//! .set_id("https://example.com".parse()?)
|
//! .set_id(uri!("https://example.com"))
|
||||||
//! .set_context(context());
|
//! .set_context(context());
|
||||||
//! Ok(())
|
//! Ok(())
|
||||||
//! }
|
//! }
|
||||||
|
@ -205,7 +205,7 @@
|
||||||
//! context,
|
//! context,
|
||||||
//! object::{ApObject, Video},
|
//! object::{ApObject, Video},
|
||||||
//! prelude::*,
|
//! prelude::*,
|
||||||
//! primitives::XsdAnyUri,
|
//! uri,
|
||||||
//! };
|
//! };
|
||||||
//!
|
//!
|
||||||
//! fn main() -> Result<(), anyhow::Error> {
|
//! fn main() -> Result<(), anyhow::Error> {
|
||||||
|
@ -213,12 +213,12 @@
|
||||||
//!
|
//!
|
||||||
//! video
|
//! video
|
||||||
//! .set_context(context())
|
//! .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_media_type("video/webm".parse()?)
|
||||||
//! .set_url("https://example.com/@example/lions/video.webm".parse::<XsdAnyUri>()?)
|
//! .set_url(uri!("https://example.com/@example/lions/video.webm"))
|
||||||
//! .set_summary("A cool video")
|
//! .set_summary("A cool video")
|
||||||
//! .set_duration("PT4M20S".parse()?)
|
//! .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);
|
//! println!("Video, {:#?}", video);
|
||||||
//!
|
//!
|
||||||
|
@ -332,47 +332,44 @@ pub mod prelude {
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! # fn main() -> Result<(), anyhow::Error> {
|
//! # fn main() -> Result<(), anyhow::Error> {
|
||||||
//! use activitystreams_new::{
|
//! use activitystreams_new::{
|
||||||
//! activity::{kind::CreateType, Create},
|
//! activity::Create,
|
||||||
//! actor::{kind::PersonType, ApActor, Person},
|
//! actor::{ApActor, Person},
|
||||||
//! context,
|
//! context,
|
||||||
//! prelude::*,
|
//! prelude::*,
|
||||||
//! primitives::XsdAnyUri,
|
|
||||||
//! public,
|
//! public,
|
||||||
//! object::{
|
//! object::{ApObject, Image, Video},
|
||||||
//! kind::{ImageType, VideoType},
|
//! security,
|
||||||
//! ApObject, Image, Video
|
//! uri,
|
||||||
//! },
|
|
||||||
//! security
|
|
||||||
//! };
|
//! };
|
||||||
//!
|
//!
|
||||||
//! let mut person = ApActor::new(
|
//! let mut person = ApActor::new(
|
||||||
//! "http://localhost:8080/inbox".parse()?,
|
//! uri!("http://localhost:8080/inbox"),
|
||||||
//! Person::new(),
|
//! Person::new(),
|
||||||
//! );
|
//! );
|
||||||
//! person
|
//! person
|
||||||
//! .set_outbox("http:/localhost:8080/outbox".parse()?)
|
//! .set_outbox(uri!("http:/localhost:8080/outbox"))
|
||||||
//! .set_name("Demo Account")
|
//! .set_name("Demo Account")
|
||||||
//! .set_preferred_username("demo")
|
//! .set_preferred_username("demo")
|
||||||
//! .set_id("https://localhost:8080/actor".parse()?)
|
//! .set_id(uri!("https://localhost:8080/actor"))
|
||||||
//! .set_url("https://localhost:8080/actor".parse::<XsdAnyUri>()?);
|
//! .set_url(uri!("https://localhost:8080/actor"));
|
||||||
//!
|
//!
|
||||||
//! let mut preview = Image::new();
|
//! let mut preview = Image::new();
|
||||||
//!
|
//!
|
||||||
//! preview
|
//! preview
|
||||||
//! .set_url("https://localhost:8080/preview.png".parse::<XsdAnyUri>()?)
|
//! .set_url(uri!("https://localhost:8080/preview.png"))
|
||||||
//! .set_media_type("image/png".parse()?)
|
//! .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());
|
//! let mut video = ApObject::new(Video::new());
|
||||||
//!
|
//!
|
||||||
//! video
|
//! video
|
||||||
//! .set_id("http://localhost:8080/video.webm".parse()?)
|
//! .set_id(uri!("http://localhost:8080/video.webm"))
|
||||||
//! .set_url("http://localhost:8080/video.webm".parse::<XsdAnyUri>()?)
|
//! .set_url(uri!("http://localhost:8080/video.webm"))
|
||||||
//! .set_media_type("video/webm".parse()?)
|
//! .set_media_type("video/webm".parse()?)
|
||||||
//! .set_summary("A cool video")
|
//! .set_summary("A cool video")
|
||||||
//! .set_preview(preview.into_any_base()?)
|
//! .set_preview(preview.into_any_base()?)
|
||||||
//! .set_duration("PT4M20S".parse()?)
|
//! .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(
|
//! let mut activity = Create::new(
|
||||||
//! person.into_any_base()?,
|
//! person.into_any_base()?,
|
||||||
|
@ -398,3 +395,24 @@ pub mod prelude {
|
||||||
object::{ApObjectExt, ObjectExt, PlaceExt, ProfileExt, RelationshipExt, TombstoneExt},
|
object::{ApObjectExt, ObjectExt, PlaceExt, ProfileExt, RelationshipExt, TombstoneExt},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A macro to shorten the `string.parse::<XsdAnyUri>()?` 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::<XsdAnyUri>()?
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
|
38
src/link.rs
38
src/link.rs
|
@ -6,15 +6,15 @@
|
||||||
//! link::Mention,
|
//! link::Mention,
|
||||||
//! object::Image,
|
//! object::Image,
|
||||||
//! prelude::*,
|
//! prelude::*,
|
||||||
//! primitives::XsdAnyUri,
|
//! uri,
|
||||||
//! };
|
//! };
|
||||||
//!
|
//!
|
||||||
//! let mut mention = Mention::new();
|
//! let mut mention = Mention::new();
|
||||||
//!
|
//!
|
||||||
//! mention
|
//! mention
|
||||||
//! .set_href("https://example.com".parse()?)
|
//! .set_href(uri!("https://example.com"))
|
||||||
//! .set_hreflang("en".into())
|
//! .set_hreflang("en")
|
||||||
//! .set_rel("link".into())
|
//! .set_rel("link")
|
||||||
//! .set_preview(Image::new().into_any_base()?);
|
//! .set_preview(Image::new().into_any_base()?);
|
||||||
//! #
|
//! #
|
||||||
//! # Ok(())
|
//! # Ok(())
|
||||||
|
@ -80,12 +80,12 @@ pub trait LinkExt<Kind>: AsLink<Kind> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// # use activitystreams_new::link::Mention;
|
/// # use activitystreams_new::{link::Mention, uri};
|
||||||
/// # let mut mention = Mention::new();
|
/// # let mut mention = Mention::new();
|
||||||
/// #
|
/// #
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
/// mention.set_href("https://example.com".parse()?);
|
/// mention.set_href(uri!("https://example.com"));
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -114,9 +114,9 @@ pub trait LinkExt<Kind>: AsLink<Kind> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// # use activitystreams_new::link::Mention;
|
/// # use activitystreams_new::{link::Mention, uri};
|
||||||
/// # let mut mention = Mention::new();
|
/// # let mut mention = Mention::new();
|
||||||
/// # mention.set_href("https://example.com".parse()?);
|
/// # mention.set_href(uri!("https://example.com"));
|
||||||
/// #
|
/// #
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
|
@ -158,10 +158,13 @@ pub trait LinkExt<Kind>: AsLink<Kind> {
|
||||||
/// #
|
/// #
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
/// mention.set_hreflang("en".into());
|
/// mention.set_hreflang("en");
|
||||||
/// ```
|
/// ```
|
||||||
fn set_hreflang(&mut self, hreflang: String) -> &mut Self {
|
fn set_hreflang<T>(&mut self, hreflang: T) -> &mut Self
|
||||||
self.link_mut().hreflang = Some(hreflang);
|
where
|
||||||
|
T: Into<String>,
|
||||||
|
{
|
||||||
|
self.link_mut().hreflang = Some(hreflang.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +190,7 @@ pub trait LinkExt<Kind>: AsLink<Kind> {
|
||||||
/// # fn main() -> Result<(), anyhow::Error> {
|
/// # fn main() -> Result<(), anyhow::Error> {
|
||||||
/// # use activitystreams_new::link::Mention;
|
/// # use activitystreams_new::link::Mention;
|
||||||
/// # let mut mention = Mention::new();
|
/// # let mut mention = Mention::new();
|
||||||
/// # mention.set_hreflang("https://example.com".parse()?);
|
/// # mention.set_hreflang("en");
|
||||||
/// #
|
/// #
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
|
@ -229,10 +232,13 @@ pub trait LinkExt<Kind>: AsLink<Kind> {
|
||||||
/// #
|
/// #
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
/// mention.set_rel("link".into());
|
/// mention.set_rel("link");
|
||||||
/// ```
|
/// ```
|
||||||
fn set_rel(&mut self, rel: String) -> &mut Self {
|
fn set_rel<T>(&mut self, rel: T) -> &mut Self
|
||||||
self.link_mut().rel = Some(rel.into());
|
where
|
||||||
|
T: Into<String>,
|
||||||
|
{
|
||||||
|
self.link_mut().rel = Some(rel.into().into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,7 +310,7 @@ pub trait LinkExt<Kind>: AsLink<Kind> {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use activitystreams_new::link::Mention;
|
/// # use activitystreams_new::link::Mention;
|
||||||
/// # let mut mention = Mention::new();
|
/// # let mut mention = Mention::new();
|
||||||
/// # mention.set_rel("link".into());
|
/// # mention.set_rel("link");
|
||||||
/// #
|
/// #
|
||||||
/// use activitystreams_new::prelude::*;
|
/// use activitystreams_new::prelude::*;
|
||||||
///
|
///
|
||||||
|
|
412
src/object.rs
412
src/object.rs
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue