2020-05-14 03:54:50 +00:00
|
|
|
use crate::{
|
2020-05-15 22:01:29 +00:00
|
|
|
base::{AnyBase, AsBase, Base, Extends},
|
|
|
|
markers,
|
|
|
|
primitives::{AnyString, OneOrMany, Unit, XsdAnyUri, XsdDateTime, XsdDuration, XsdFloat},
|
|
|
|
unparsed::{Unparsed, UnparsedMut, UnparsedMutExt},
|
2020-05-14 03:54:50 +00:00
|
|
|
};
|
|
|
|
use std::convert::TryFrom;
|
2020-05-14 16:23:38 +00:00
|
|
|
use typed_builder::TypedBuilder;
|
2020-05-14 03:54:50 +00:00
|
|
|
|
|
|
|
pub mod kind {
|
|
|
|
pub use activitystreams::object::kind::*;
|
|
|
|
}
|
|
|
|
|
|
|
|
use self::kind::*;
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
pub trait AsObject<Kind>: markers::Object {
|
2020-05-15 03:18:34 +00:00
|
|
|
fn object_ref(&self) -> &Object<Kind>;
|
|
|
|
fn object_mut(&mut self) -> &mut Object<Kind>;
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
pub trait AsApObject<Inner>: markers::Object {
|
2020-05-15 03:18:34 +00:00
|
|
|
fn ap_object_ref(&self) -> &ApObject<Inner>;
|
|
|
|
fn ap_object_mut(&mut self) -> &mut ApObject<Inner>;
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
pub trait AsPlace: markers::Object {
|
2020-05-15 03:18:34 +00:00
|
|
|
fn place_ref(&self) -> &Place;
|
|
|
|
fn place_mut(&mut self) -> &mut Place;
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
pub trait AsProfile: markers::Object {
|
2020-05-15 03:18:34 +00:00
|
|
|
fn profile_ref(&self) -> &Profile;
|
|
|
|
fn profile_mut(&mut self) -> &mut Profile;
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
pub trait AsRelationship: markers::Object {
|
2020-05-15 03:18:34 +00:00
|
|
|
fn relationship_ref(&self) -> &Relationship;
|
|
|
|
fn relationship_mut(&mut self) -> &mut Relationship;
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
pub trait AsTombstone: markers::Object {
|
2020-05-15 03:18:34 +00:00
|
|
|
fn tombstone_ref(&self) -> &Tombstone;
|
|
|
|
fn tombstone_mut(&mut self) -> &mut Tombstone;
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
pub trait ObjectExt<Kind>: AsObject<Kind> {
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Fetch the attachment for the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(attachment) = video.attachment() {
|
|
|
|
/// println!("{:?}", attachment);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn attachment<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
2020-05-15 03:18:34 +00:00
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().attachment.as_ref()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Set the attachment for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of attachment
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_attachment("https://example.com".parse::<XsdAnyUri>()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_attachment<T>(&mut self, attachment: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
self.object_mut().attachment = Some(attachment.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Set many attachments for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of attachment
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_many_attachments(vec![
|
|
|
|
/// "https://example.com/one".parse::<XsdAnyUri>()?,
|
|
|
|
/// "https://example.com/two".parse()?,
|
|
|
|
/// ]);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_many_attachments<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.object_mut().attachment = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Add a attachment to the current object
|
|
|
|
///
|
|
|
|
/// This does not overwrite the contents of attachment, only appends an item
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video
|
|
|
|
/// .add_attachment("https://example.com/one".parse::<XsdAnyUri>()?)
|
|
|
|
/// .add_attachment("https://example.com/two".parse::<XsdAnyUri>()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn add_attachment<T>(&mut self, attachment: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
let a = match self.object_mut().attachment.take() {
|
|
|
|
Some(mut a) => {
|
|
|
|
a.add(attachment.into());
|
|
|
|
a
|
|
|
|
}
|
|
|
|
None => vec![attachment.into()].into(),
|
|
|
|
};
|
|
|
|
self.object_mut().attachment = Some(a);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Take the attachment from the current object, leaving nothing
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(attachment) = video.take_attachment() {
|
|
|
|
/// println!("{:?}", attachment);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn take_attachment(&mut self) -> Option<OneOrMany<AnyBase>> {
|
2020-05-15 03:18:34 +00:00
|
|
|
self.object_mut().attachment.take()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Delete the attachment from the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// # video.set_attachment("https://example.com".parse::<XsdAnyUri>()?);
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// assert!(video.attachment().is_some());
|
|
|
|
/// video.delete_attachment();
|
|
|
|
/// assert!(video.attachment().is_none());
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn delete_attachment(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().attachment = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Fetch the attributed_to for the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(attributed_to) = video.attributed_to() {
|
|
|
|
/// println!("{:?}", attributed_to);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn attributed_to<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().attributed_to.as_ref()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Set the attributed_to for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of attributed_to
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_attributed_to("https://example.com".parse::<XsdAnyUri>()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_attributed_to<T>(&mut self, attributed_to: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
self.object_mut().attributed_to = Some(attributed_to.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Set many attributed_tos for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of attributed_to
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_many_attributed_tos(vec![
|
|
|
|
/// "https://example.com/one".parse::<XsdAnyUri>()?,
|
|
|
|
/// "https://example.com/two".parse()?,
|
|
|
|
/// ]);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_many_attributed_tos<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.object_mut().attributed_to = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Add a attributed_to to the current object
|
|
|
|
///
|
|
|
|
/// This does not overwrite the contents of attributed_to, only appends an item
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video
|
|
|
|
/// .add_attributed_to("https://example.com/one".parse::<XsdAnyUri>()?)
|
|
|
|
/// .add_attributed_to("https://example.com/two".parse::<XsdAnyUri>()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn add_attributed_to<T>(&mut self, attributed_to: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
let a = match self.object_mut().attributed_to.take() {
|
|
|
|
Some(mut a) => {
|
|
|
|
a.add(attributed_to.into());
|
|
|
|
a
|
|
|
|
}
|
|
|
|
None => vec![attributed_to.into()].into(),
|
|
|
|
};
|
|
|
|
self.object_mut().attributed_to = Some(a);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Take the attributed_to from the current object, leaving nothing
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(attributed_to) = video.take_attributed_to() {
|
|
|
|
/// println!("{:?}", attributed_to);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn take_attributed_to(&mut self) -> Option<OneOrMany<AnyBase>> {
|
2020-05-15 03:18:34 +00:00
|
|
|
self.object_mut().attributed_to.take()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Delete the attributed_to from the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// # video.set_attributed_to("https://example.com".parse::<XsdAnyUri>()?);
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// assert!(video.attributed_to().is_some());
|
|
|
|
/// video.delete_attributed_to();
|
|
|
|
/// assert!(video.attributed_to().is_none());
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn delete_attributed_to(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().attributed_to = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Fetch the audience for the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(audience) = video.audience() {
|
|
|
|
/// println!("{:?}", audience);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn audience<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().audience.as_ref()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Set the audience for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of audience
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_audience("https://example.com".parse::<XsdAnyUri>()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_audience<T>(&mut self, audience: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
self.object_mut().audience = Some(audience.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// This overwrites the contents of audience
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_many_audiences(vec![
|
|
|
|
/// "https://example.com/one".parse::<XsdAnyUri>()?,
|
|
|
|
/// "https://example.com/two".parse()?,
|
|
|
|
/// ]);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_many_audiences<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.object_mut().audience = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Add a audience to the current object
|
|
|
|
///
|
|
|
|
/// This does not overwrite the contents of audience, only appends an item
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video
|
|
|
|
/// .add_audience("https://example.com/one".parse::<XsdAnyUri>()?)
|
|
|
|
/// .add_audience("https://example.com/two".parse::<XsdAnyUri>()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn add_audience<T>(&mut self, audience: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
let a = match self.object_mut().audience.take() {
|
|
|
|
Some(mut a) => {
|
|
|
|
a.add(audience.into());
|
|
|
|
a
|
|
|
|
}
|
|
|
|
None => vec![audience.into()].into(),
|
|
|
|
};
|
|
|
|
self.object_mut().audience = Some(a);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Take the audience from the current object, leaving nothing
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(audience) = video.take_audience() {
|
|
|
|
/// println!("{:?}", audience);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn take_audience(&mut self) -> Option<OneOrMany<AnyBase>> {
|
2020-05-15 03:18:34 +00:00
|
|
|
self.object_mut().audience.take()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Delete the audience from the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// # video.set_audience("https://example.com".parse::<XsdAnyUri>()?);
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// assert!(video.audience().is_some());
|
|
|
|
/// video.delete_audience();
|
|
|
|
/// assert!(video.audience().is_none());
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn delete_audience(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().audience = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Fetch the content for the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(content) = video.content() {
|
|
|
|
/// println!("{:?}", content);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn content<'a>(&'a self) -> Option<&'a OneOrMany<AnyString>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().content.as_ref()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Set the content for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of content
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdString};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_content(XsdString::from("hi"));
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_content<T>(&mut self, content: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyString>,
|
|
|
|
{
|
|
|
|
self.object_mut().content = Some(content.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Set many contents for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of content
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdString};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_many_contents(vec![
|
|
|
|
/// XsdString::from("hi"),
|
|
|
|
/// "hello".into(),
|
|
|
|
/// ]);
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_many_contents<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
|
|
|
T: Into<AnyString>,
|
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.object_mut().content = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Add a content to the current object
|
|
|
|
///
|
|
|
|
/// This does not overwrite the contents of content, only appends an item
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdString};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video
|
|
|
|
/// .add_content(XsdString::from("hi"))
|
|
|
|
/// .add_content(XsdString::from("hello"));
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn add_content<T>(&mut self, content: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyString>,
|
|
|
|
{
|
|
|
|
let a = match self.object_mut().content.take() {
|
|
|
|
Some(mut a) => {
|
|
|
|
a.add(content.into());
|
|
|
|
a
|
|
|
|
}
|
|
|
|
None => vec![content.into()].into(),
|
|
|
|
};
|
|
|
|
self.object_mut().content = Some(a);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Take the content from the current object, leaving nothing
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(content) = video.take_content() {
|
|
|
|
/// println!("{:?}", content);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn take_content(&mut self) -> Option<OneOrMany<AnyString>> {
|
|
|
|
self.object_mut().content.take()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Delete the content from the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdString};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// # video.set_content(XsdString::from("https://example.com"));
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// assert!(video.content().is_some());
|
|
|
|
/// video.delete_content();
|
|
|
|
/// assert!(video.content().is_none());
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn delete_content(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().content = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Fetch the summary for the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(summary) = video.summary() {
|
|
|
|
/// println!("{:?}", summary);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn summary<'a>(&'a self) -> Option<&'a OneOrMany<AnyString>>
|
2020-05-15 03:18:34 +00:00
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
Kind: 'a,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
2020-05-15 22:01:29 +00:00
|
|
|
self.object_ref().summary.as_ref()
|
2020-05-15 03:18:34 +00:00
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Set the summary for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of summary
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdString};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_summary(XsdString::from("hi"));
|
|
|
|
/// ```
|
|
|
|
fn set_summary<T>(&mut self, summary: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 03:18:34 +00:00
|
|
|
T: Into<AnyString>,
|
|
|
|
{
|
|
|
|
self.object_mut().summary = Some(summary.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Set many summaries for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of summary
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdString};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_many_summaries(vec![
|
|
|
|
/// XsdString::from("hi"),
|
|
|
|
/// "hello".into(),
|
|
|
|
/// ]);
|
|
|
|
/// ```
|
|
|
|
fn set_many_summaries<I, T>(&mut self, items: I) -> &mut Self
|
2020-05-15 03:18:34 +00:00
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
|
|
|
T: Into<AnyString>,
|
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.object_mut().summary = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Add a summary to the current object
|
|
|
|
///
|
|
|
|
/// This does not overwrite the contents of summary, only appends an item
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdString};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video
|
|
|
|
/// .add_summary(XsdString::from("hi"))
|
|
|
|
/// .add_summary(XsdString::from("hello"));
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn add_summary<T>(&mut self, summary: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyString>,
|
|
|
|
{
|
|
|
|
let a = match self.object_mut().summary.take() {
|
|
|
|
Some(mut a) => {
|
|
|
|
a.add(summary.into());
|
|
|
|
a
|
|
|
|
}
|
|
|
|
None => vec![summary.into()].into(),
|
|
|
|
};
|
|
|
|
self.object_mut().summary = Some(a);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Take the summary from the current object, leaving nothing
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(summary) = video.take_summary() {
|
|
|
|
/// println!("{:?}", summary);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn take_summary(&mut self) -> Option<OneOrMany<AnyString>> {
|
|
|
|
self.object_mut().summary.take()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Delete the summary from the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdString};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// # video.set_summary(XsdString::from("https://example.com"));
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// assert!(video.summary().is_some());
|
|
|
|
/// video.delete_summary();
|
|
|
|
/// assert!(video.summary().is_none());
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn delete_summary(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().summary = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Fetch the url for the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(url) = video.url() {
|
|
|
|
/// println!("{:?}", url);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn url<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().url.as_ref()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Set the url for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of url
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_url("https://example.com".parse::<XsdAnyUri>()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_url<T>(&mut self, url: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
self.object_mut().url = Some(url.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Set many urls for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of url
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_many_urls(vec![
|
|
|
|
/// "https://example.com/one".parse::<XsdAnyUri>()?,
|
|
|
|
/// "https://example.com/two".parse()?,
|
|
|
|
/// ]);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_many_urls<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.object_mut().url = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Add a url to the current object
|
|
|
|
///
|
|
|
|
/// This does not overwrite the contents of url, only appends an item
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video
|
|
|
|
/// .add_url("https://example.com/one".parse::<XsdAnyUri>()?)
|
|
|
|
/// .add_url("https://example.com/two".parse::<XsdAnyUri>()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn add_url<T>(&mut self, url: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
let a = match self.object_mut().url.take() {
|
|
|
|
Some(mut a) => {
|
|
|
|
a.add(url.into());
|
|
|
|
a
|
|
|
|
}
|
|
|
|
None => vec![url.into()].into(),
|
|
|
|
};
|
|
|
|
self.object_mut().url = Some(a);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Take the url from the current object, leaving nothing
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(url) = video.take_url() {
|
|
|
|
/// println!("{:?}", url);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn take_url(&mut self) -> Option<OneOrMany<AnyBase>> {
|
2020-05-15 03:18:34 +00:00
|
|
|
self.object_mut().url.take()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Delete the url from the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// # video.set_url("https://example.com".parse::<XsdAnyUri>()?);
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// assert!(video.url().is_some());
|
|
|
|
/// video.delete_url();
|
|
|
|
/// assert!(video.url().is_none());
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn delete_url(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().url = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Fetch the generator for the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(generator) = video.generator() {
|
|
|
|
/// println!("{:?}", generator);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn generator<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().generator.as_ref()
|
2020-05-15 03:18:34 +00:00
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Set the generator for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of generator
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_generator("https://example.com".parse::<XsdAnyUri>()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_generator<T>(&mut self, generator: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
self.object_mut().generator = Some(generator.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Set many generators for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of generator
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_many_generators(vec![
|
|
|
|
/// "https://example.com/one".parse::<XsdAnyUri>()?,
|
|
|
|
/// "https://example.com/two".parse()?,
|
|
|
|
/// ]);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_many_generators<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.object_mut().generator = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Add a generator to the current object
|
|
|
|
///
|
|
|
|
/// This does not overwrite the contents of generator, only appends an item
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video
|
|
|
|
/// .add_generator("https://example.com/one".parse::<XsdAnyUri>()?)
|
|
|
|
/// .add_generator("https://example.com/two".parse::<XsdAnyUri>()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn add_generator<T>(&mut self, generator: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
let a = match self.object_mut().generator.take() {
|
|
|
|
Some(mut a) => {
|
|
|
|
a.add(generator.into());
|
|
|
|
a
|
|
|
|
}
|
|
|
|
None => vec![generator.into()].into(),
|
|
|
|
};
|
|
|
|
self.object_mut().generator = Some(a);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Take the generator from the current object, leaving nothing
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(generator) = video.take_generator() {
|
|
|
|
/// println!("{:?}", generator);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn take_generator(&mut self) -> Option<OneOrMany<AnyBase>> {
|
2020-05-15 03:18:34 +00:00
|
|
|
self.object_mut().generator.take()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Delete the generator from the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// # video.set_generator("https://example.com".parse::<XsdAnyUri>()?);
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// assert!(video.generator().is_some());
|
|
|
|
/// video.delete_generator();
|
|
|
|
/// assert!(video.generator().is_none());
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn delete_generator(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().generator = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 17:34:07 +00:00
|
|
|
/// Fetch the icon for the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(icon) = video.icon() {
|
|
|
|
/// println!("{:?}", icon);
|
|
|
|
/// }
|
|
|
|
/// ```
|
|
|
|
fn icon<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().icon.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Set the icon for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of icon
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_icon("https://example.com".parse::<XsdAnyUri>()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
|
|
|
fn set_icon<T>(&mut self, icon: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyBase>,
|
|
|
|
{
|
|
|
|
self.object_mut().icon = Some(icon.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Set many icons for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of icon
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_many_icons(vec![
|
|
|
|
/// "https://example.com/one".parse::<XsdAnyUri>()?,
|
|
|
|
/// "https://example.com/two".parse()?,
|
|
|
|
/// ]);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
|
|
|
fn set_many_icons<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
|
|
|
T: Into<AnyBase>,
|
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.object_mut().icon = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Add a icon to the current object
|
|
|
|
///
|
|
|
|
/// This does not overwrite the contents of icon, only appends an item
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video
|
|
|
|
/// .add_icon("https://example.com/one".parse::<XsdAnyUri>()?)
|
|
|
|
/// .add_icon("https://example.com/two".parse::<XsdAnyUri>()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
|
|
|
fn add_icon<T>(&mut self, icon: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyBase>,
|
|
|
|
{
|
|
|
|
let a = match self.object_mut().icon.take() {
|
|
|
|
Some(mut a) => {
|
|
|
|
a.add(icon.into());
|
|
|
|
a
|
|
|
|
}
|
|
|
|
None => vec![icon.into()].into(),
|
|
|
|
};
|
|
|
|
self.object_mut().icon = Some(a);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Take the icon from the current object, leaving nothing
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(icon) = video.take_icon() {
|
|
|
|
/// println!("{:?}", icon);
|
|
|
|
/// }
|
|
|
|
/// ```
|
|
|
|
fn take_icon(&mut self) -> Option<OneOrMany<AnyBase>> {
|
|
|
|
self.object_mut().icon.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Delete the icon from the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// # video.set_icon("https://example.com".parse::<XsdAnyUri>()?);
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// assert!(video.icon().is_some());
|
|
|
|
/// video.delete_icon();
|
|
|
|
/// assert!(video.icon().is_none());
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
|
|
|
fn delete_icon(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().icon = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Fetch the image for the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(image) = video.image() {
|
|
|
|
/// println!("{:?}", image);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn image<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().image.as_ref()
|
|
|
|
}
|
|
|
|
|
2020-05-16 17:34:07 +00:00
|
|
|
/// Set the image for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of image
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_image("https://example.com".parse::<XsdAnyUri>()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_image<T>(&mut self, image: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
self.object_mut().image = Some(image.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 17:34:07 +00:00
|
|
|
/// Set many images for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of image
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_many_images(vec![
|
|
|
|
/// "https://example.com/one".parse::<XsdAnyUri>()?,
|
|
|
|
/// "https://example.com/two".parse()?,
|
|
|
|
/// ]);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_many_images<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.object_mut().image = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 17:34:07 +00:00
|
|
|
/// Add a image to the current object
|
|
|
|
///
|
|
|
|
/// This does not overwrite the contents of image, only appends an item
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video
|
|
|
|
/// .add_image("https://example.com/one".parse::<XsdAnyUri>()?)
|
|
|
|
/// .add_image("https://example.com/two".parse::<XsdAnyUri>()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn add_image<T>(&mut self, image: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
let a = match self.object_mut().image.take() {
|
|
|
|
Some(mut a) => {
|
|
|
|
a.add(image.into());
|
|
|
|
a
|
|
|
|
}
|
|
|
|
None => vec![image.into()].into(),
|
|
|
|
};
|
|
|
|
self.object_mut().image = Some(a);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 17:34:07 +00:00
|
|
|
/// Take the image from the current object, leaving nothing
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(image) = video.take_image() {
|
|
|
|
/// println!("{:?}", image);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn take_image(&mut self) -> Option<OneOrMany<AnyBase>> {
|
2020-05-15 03:18:34 +00:00
|
|
|
self.object_mut().image.take()
|
|
|
|
}
|
|
|
|
|
2020-05-16 17:34:07 +00:00
|
|
|
/// Delete the image from the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// # video.set_image("https://example.com".parse::<XsdAnyUri>()?);
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// assert!(video.image().is_some());
|
|
|
|
/// video.delete_image();
|
|
|
|
/// assert!(video.image().is_none());
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn delete_image(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().image = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Fetch the location for the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(location) = video.location() {
|
|
|
|
/// println!("{:?}", location);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn location<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().location.as_ref()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Set the location for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of location
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_location("https://example.com".parse::<XsdAnyUri>()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_location<T>(&mut self, location: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
self.object_mut().location = Some(location.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Set many locations for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of location
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_many_locations(vec![
|
|
|
|
/// "https://example.com/one".parse::<XsdAnyUri>()?,
|
|
|
|
/// "https://example.com/two".parse()?,
|
|
|
|
/// ]);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_many_locations<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.object_mut().location = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Add a location to the current object
|
|
|
|
///
|
|
|
|
/// This does not overwrite the contents of location, only appends an item
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video
|
|
|
|
/// .add_location("https://example.com/one".parse::<XsdAnyUri>()?)
|
|
|
|
/// .add_location("https://example.com/two".parse::<XsdAnyUri>()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn add_location<T>(&mut self, location: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
let a = match self.object_mut().location.take() {
|
|
|
|
Some(mut a) => {
|
|
|
|
a.add(location.into());
|
|
|
|
a
|
|
|
|
}
|
|
|
|
None => vec![location.into()].into(),
|
|
|
|
};
|
|
|
|
self.object_mut().location = Some(a);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Take the location from the current object, leaving nothing
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(location) = video.take_location() {
|
|
|
|
/// println!("{:?}", location);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn take_location(&mut self) -> Option<OneOrMany<AnyBase>> {
|
2020-05-15 03:18:34 +00:00
|
|
|
self.object_mut().location.take()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Delete the location from the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// # video.set_location("https://example.com".parse::<XsdAnyUri>()?);
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// assert!(video.location().is_some());
|
|
|
|
/// video.delete_location();
|
|
|
|
/// assert!(video.location().is_none());
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn delete_location(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().location = None;
|
2020-05-16 17:34:07 +00:00
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Fetch the tag for the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(tag) = video.tag() {
|
|
|
|
/// println!("{:?}", tag);
|
|
|
|
/// }
|
|
|
|
/// ```
|
|
|
|
fn tag<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().tag.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Set the tag for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of tag
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_tag("https://example.com".parse::<XsdAnyUri>()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
|
|
|
fn set_tag<T>(&mut self, tag: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyBase>,
|
|
|
|
{
|
|
|
|
self.object_mut().tag = Some(tag.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Set many tags for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of tag
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_many_tags(vec![
|
|
|
|
/// "https://example.com/one".parse::<XsdAnyUri>()?,
|
|
|
|
/// "https://example.com/two".parse()?,
|
|
|
|
/// ]);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
|
|
|
fn set_many_tags<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
|
|
|
T: Into<AnyBase>,
|
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.object_mut().tag = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Add a tag to the current object
|
|
|
|
///
|
|
|
|
/// This does not overwrite the contents of tag, only appends an item
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video
|
|
|
|
/// .add_tag("https://example.com/one".parse::<XsdAnyUri>()?)
|
|
|
|
/// .add_tag("https://example.com/two".parse::<XsdAnyUri>()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
|
|
|
fn add_tag<T>(&mut self, tag: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyBase>,
|
|
|
|
{
|
|
|
|
let a = match self.object_mut().tag.take() {
|
|
|
|
Some(mut a) => {
|
|
|
|
a.add(tag.into());
|
|
|
|
a
|
|
|
|
}
|
|
|
|
None => vec![tag.into()].into(),
|
|
|
|
};
|
|
|
|
self.object_mut().tag = Some(a);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Take the tag from the current object, leaving nothing
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(tag) = video.take_tag() {
|
|
|
|
/// println!("{:?}", tag);
|
|
|
|
/// }
|
|
|
|
/// ```
|
|
|
|
fn take_tag(&mut self) -> Option<OneOrMany<AnyBase>> {
|
|
|
|
self.object_mut().tag.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Delete the tag from the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// # video.set_tag("https://example.com".parse::<XsdAnyUri>()?);
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// assert!(video.tag().is_some());
|
|
|
|
/// video.delete_tag();
|
|
|
|
/// assert!(video.tag().is_none());
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
|
|
|
fn delete_tag(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().tag = None;
|
2020-05-15 03:18:34 +00:00
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Fetch the start_time for the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(start_time) = video.start_time() {
|
|
|
|
/// println!("{:?}", start_time);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn start_time<'a>(&'a self) -> Option<&'a XsdDateTime>
|
2020-05-15 03:18:34 +00:00
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
Kind: 'a,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
2020-05-15 22:01:29 +00:00
|
|
|
self.object_ref().start_time.as_ref()
|
2020-05-15 03:18:34 +00:00
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Set the start_time for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of start_time
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdDateTime};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_start_time("2020-04-20T04:20:00Z".parse()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
|
|
|
fn set_start_time(&mut self, start_time: XsdDateTime) -> &mut Self {
|
|
|
|
self.object_mut().start_time = Some(start_time);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Take the start_time from the current object, leaving nothing
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(start_time) = video.take_start_time() {
|
|
|
|
/// println!("{:?}", start_time);
|
|
|
|
/// }
|
|
|
|
/// ```
|
|
|
|
fn take_start_time(&mut self) -> Option<XsdDateTime> {
|
|
|
|
self.object_mut().start_time.take()
|
|
|
|
}
|
2020-05-15 03:18:34 +00:00
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Delete the start_time from the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// # video.set_start_time("2020-04-20T04:20:00Z".parse()?);
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// assert!(video.start_time().is_some());
|
|
|
|
/// video.delete_start_time();
|
|
|
|
/// assert!(video.start_time().is_none());
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn delete_start_time(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().start_time = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Fetch the end_time for the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(end_time) = video.end_time() {
|
|
|
|
/// println!("{:?}", end_time);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn end_time<'a>(&'a self) -> Option<&'a XsdDateTime>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().end_time.as_ref()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Set the end_time for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of end_time
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdDateTime};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_end_time("2020-04-20T04:20:00-05:00".parse()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_end_time(&mut self, end_time: XsdDateTime) -> &mut Self {
|
|
|
|
self.object_mut().end_time = Some(end_time);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Take the end_time from the current object, leaving nothing
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(end_time) = video.take_end_time() {
|
|
|
|
/// println!("{:?}", end_time);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn take_end_time(&mut self) -> Option<XsdDateTime> {
|
|
|
|
self.object_mut().end_time.take()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Delete the end_time from the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// # video.set_end_time("2020-04-20T04:20:00Z".parse()?);
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// assert!(video.end_time().is_some());
|
|
|
|
/// video.delete_end_time();
|
|
|
|
/// assert!(video.end_time().is_none());
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn delete_end_time(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().end_time = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Fetch the duration for the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(duration) = video.duration() {
|
|
|
|
/// println!("{:?}", duration);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn duration<'a>(&'a self) -> Option<&'a XsdDuration>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().duration.as_ref()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Set the duration for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of duration
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdDateTime};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_duration("P3DT1H".parse()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_duration(&mut self, duration: XsdDuration) -> &mut Self {
|
|
|
|
self.object_mut().duration = Some(duration);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Take the duration from the current object, leaving nothing
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(duration) = video.take_duration() {
|
|
|
|
/// println!("{:?}", duration);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn take_duration(&mut self) -> Option<XsdDuration> {
|
|
|
|
self.object_mut().duration.take()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Delete the duration from the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// # video.set_duration("P1Y2MT3M30S".parse()?);
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// assert!(video.duration().is_some());
|
|
|
|
/// video.delete_duration();
|
|
|
|
/// assert!(video.duration().is_none());
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn delete_duration(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().duration = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Fetch the published for the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(published) = video.published() {
|
|
|
|
/// println!("{:?}", published);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn published<'a>(&'a self) -> Option<&'a XsdDateTime>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().published.as_ref()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Set the published for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of published
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdDateTime};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_published("2020-04-20T04:20:00Z".parse()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_published(&mut self, published: XsdDateTime) -> &mut Self {
|
|
|
|
self.object_mut().published = Some(published);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Take the published from the current object, leaving nothing
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(published) = video.take_published() {
|
|
|
|
/// println!("{:?}", published);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn take_published(&mut self) -> Option<XsdDateTime> {
|
|
|
|
self.object_mut().published.take()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Delete the published from the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// # video.set_published("2020-04-20T04:20:00Z".parse()?);
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// assert!(video.published().is_some());
|
|
|
|
/// video.delete_published();
|
|
|
|
/// assert!(video.published().is_none());
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn delete_published(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().published = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Fetch the updated for the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(updated) = video.updated() {
|
|
|
|
/// println!("{:?}", updated);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn updated<'a>(&'a self) -> Option<&'a XsdDateTime>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().updated.as_ref()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Set the updated for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of updated
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdDateTime};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_updated("2020-04-20T04:20:00Z".parse()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_updated(&mut self, updated: XsdDateTime) -> &mut Self {
|
|
|
|
self.object_mut().updated = Some(updated);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Take the updated from the current object, leaving nothing
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(updated) = video.take_updated() {
|
|
|
|
/// println!("{:?}", updated);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn take_updated(&mut self) -> Option<XsdDateTime> {
|
|
|
|
self.object_mut().updated.take()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Delete the updated from the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// # video.set_updated("2020-04-20T04:20:00Z".parse()?);
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// assert!(video.updated().is_some());
|
|
|
|
/// video.delete_updated();
|
|
|
|
/// assert!(video.updated().is_none());
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn delete_updated(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().updated = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Fetch the in_reply_to for the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(in_reply_to) = video.in_reply_to() {
|
|
|
|
/// println!("{:?}", in_reply_to);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn in_reply_to<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().in_reply_to.as_ref()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Set the in_reply_to for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of in_reply_to
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_in_reply_to("https://example.com".parse::<XsdAnyUri>()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_in_reply_to<T>(&mut self, in_reply_to: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
self.object_mut().in_reply_to = Some(in_reply_to.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Set many in_reply_tos for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of in_reply_to
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_many_in_reply_tos(vec![
|
|
|
|
/// "https://example.com/one".parse::<XsdAnyUri>()?,
|
|
|
|
/// "https://example.com/two".parse()?,
|
|
|
|
/// ]);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_many_in_reply_tos<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.object_mut().in_reply_to = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Add a in_reply_to to the current object
|
|
|
|
///
|
|
|
|
/// This does not overwrite the contents of in_reply_to, only appends an item
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video
|
|
|
|
/// .add_in_reply_to("https://example.com/one".parse::<XsdAnyUri>()?)
|
|
|
|
/// .add_in_reply_to("https://example.com/two".parse::<XsdAnyUri>()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn add_in_reply_to<T>(&mut self, in_reply_to: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
let a = match self.object_mut().in_reply_to.take() {
|
|
|
|
Some(mut a) => {
|
|
|
|
a.add(in_reply_to.into());
|
|
|
|
a
|
|
|
|
}
|
|
|
|
None => vec![in_reply_to.into()].into(),
|
|
|
|
};
|
|
|
|
self.object_mut().in_reply_to = Some(a);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Take the in_reply_to from the current object, leaving nothing
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(in_reply_to) = video.take_in_reply_to() {
|
|
|
|
/// println!("{:?}", in_reply_to);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn take_in_reply_to(&mut self) -> Option<OneOrMany<AnyBase>> {
|
2020-05-15 03:18:34 +00:00
|
|
|
self.object_mut().in_reply_to.take()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Delete the in_reply_to from the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// # video.set_in_reply_to("https://example.com".parse::<XsdAnyUri>()?);
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// assert!(video.in_reply_to().is_some());
|
|
|
|
/// video.delete_in_reply_to();
|
|
|
|
/// assert!(video.in_reply_to().is_none());
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn delete_in_reply_to(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().in_reply_to = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Fetch the replies for the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(replies) = video.replies() {
|
|
|
|
/// println!("{:?}", replies);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn replies<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().replies.as_ref()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Set the replies for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of replies
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_replies("https://example.com".parse::<XsdAnyUri>()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_replies<T>(&mut self, replies: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
self.object_mut().replies = Some(replies.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Set many replies for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of replies
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_many_replies(vec![
|
|
|
|
/// "https://example.com/one".parse::<XsdAnyUri>()?,
|
|
|
|
/// "https://example.com/two".parse()?,
|
|
|
|
/// ]);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
|
|
|
fn set_many_replies<I, T>(&mut self, items: I) -> &mut Self
|
2020-05-15 03:18:34 +00:00
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.object_mut().replies = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Add a replies to the current object
|
|
|
|
///
|
|
|
|
/// This does not overwrite the contents of replies, only appends an item
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video
|
|
|
|
/// .add_replies("https://example.com/one".parse::<XsdAnyUri>()?)
|
|
|
|
/// .add_replies("https://example.com/two".parse::<XsdAnyUri>()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn add_replies<T>(&mut self, replies: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
let a = match self.object_mut().replies.take() {
|
|
|
|
Some(mut a) => {
|
|
|
|
a.add(replies.into());
|
|
|
|
a
|
|
|
|
}
|
|
|
|
None => vec![replies.into()].into(),
|
|
|
|
};
|
|
|
|
self.object_mut().replies = Some(a);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Take the replies from the current object, leaving nothing
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(replies) = video.take_replies() {
|
|
|
|
/// println!("{:?}", replies);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn take_replies(&mut self) -> Option<OneOrMany<AnyBase>> {
|
2020-05-15 03:18:34 +00:00
|
|
|
self.object_mut().replies.take()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Delete the replies from the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// # video.set_replies("https://example.com".parse::<XsdAnyUri>()?);
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// assert!(video.replies().is_some());
|
|
|
|
/// video.delete_replies();
|
|
|
|
/// assert!(video.replies().is_none());
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn delete_replies(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().replies = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Fetch the to for the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(to) = video.to() {
|
|
|
|
/// println!("{:?}", to);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn to<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().to.as_ref()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Set the to for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of to
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_to("https://example.com".parse::<XsdAnyUri>()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_to<T>(&mut self, to: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
self.object_mut().to = Some(to.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Set many tos for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of to
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_many_tos(vec![
|
|
|
|
/// "https://example.com/one".parse::<XsdAnyUri>()?,
|
|
|
|
/// "https://example.com/two".parse()?,
|
|
|
|
/// ]);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_many_tos<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.object_mut().to = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Add a to to the current object
|
|
|
|
///
|
|
|
|
/// This does not overwrite the contents of to, only appends an item
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video
|
|
|
|
/// .add_to("https://example.com/one".parse::<XsdAnyUri>()?)
|
|
|
|
/// .add_to("https://example.com/two".parse::<XsdAnyUri>()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn add_to<T>(&mut self, to: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
let a = match self.object_mut().to.take() {
|
|
|
|
Some(mut a) => {
|
|
|
|
a.add(to.into());
|
|
|
|
a
|
|
|
|
}
|
|
|
|
None => vec![to.into()].into(),
|
|
|
|
};
|
|
|
|
self.object_mut().to = Some(a);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Take the to from the current object, leaving nothing
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(to) = video.take_to() {
|
|
|
|
/// println!("{:?}", to);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn take_to(&mut self) -> Option<OneOrMany<AnyBase>> {
|
2020-05-15 03:18:34 +00:00
|
|
|
self.object_mut().to.take()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Delete the to from the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// # video.set_to("https://example.com".parse::<XsdAnyUri>()?);
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// assert!(video.to().is_some());
|
|
|
|
/// video.delete_to();
|
|
|
|
/// assert!(video.to().is_none());
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn delete_to(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().to = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Fetch the bto for the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(bto) = video.bto() {
|
|
|
|
/// println!("{:?}", bto);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn bto<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().bto.as_ref()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Set the bto for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of bto
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_bto("https://example.com".parse::<XsdAnyUri>()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_bto<T>(&mut self, bto: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
self.object_mut().bto = Some(bto.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Set many btos for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of bto
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_many_btos(vec![
|
|
|
|
/// "https://example.com/one".parse::<XsdAnyUri>()?,
|
|
|
|
/// "https://example.com/two".parse()?,
|
|
|
|
/// ]);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_many_btos<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.object_mut().bto = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Add a bto to the current object
|
|
|
|
///
|
|
|
|
/// This does not overwrite the contents of bto, only appends an item
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video
|
|
|
|
/// .add_bto("https://example.com/one".parse::<XsdAnyUri>()?)
|
|
|
|
/// .add_bto("https://example.com/two".parse::<XsdAnyUri>()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn add_bto<T>(&mut self, bto: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
let a = match self.object_mut().bto.take() {
|
|
|
|
Some(mut a) => {
|
|
|
|
a.add(bto.into());
|
|
|
|
a
|
|
|
|
}
|
|
|
|
None => vec![bto.into()].into(),
|
|
|
|
};
|
|
|
|
self.object_mut().bto = Some(a);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Take the bto from the current object, leaving nothing
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(bto) = video.take_bto() {
|
|
|
|
/// println!("{:?}", bto);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn take_bto(&mut self) -> Option<OneOrMany<AnyBase>> {
|
2020-05-15 03:18:34 +00:00
|
|
|
self.object_mut().bto.take()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Delete the bto from the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// # video.set_bto("https://example.com".parse::<XsdAnyUri>()?);
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// assert!(video.bto().is_some());
|
|
|
|
/// video.delete_bto();
|
|
|
|
/// assert!(video.bto().is_none());
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn delete_bto(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().bto = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Fetch the cc for the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(cc) = video.cc() {
|
|
|
|
/// println!("{:?}", cc);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn cc<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().cc.as_ref()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Set the cc for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of cc
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_cc("https://example.com".parse::<XsdAnyUri>()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_cc<T>(&mut self, cc: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
self.object_mut().cc = Some(cc.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Set many ccs for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of cc
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_many_ccs(vec![
|
|
|
|
/// "https://example.com/one".parse::<XsdAnyUri>()?,
|
|
|
|
/// "https://example.com/two".parse()?,
|
|
|
|
/// ]);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_many_ccs<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.object_mut().cc = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Add a cc to the current object
|
|
|
|
///
|
|
|
|
/// This does not overwrite the contents of cc, only appends an item
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video
|
|
|
|
/// .add_cc("https://example.com/one".parse::<XsdAnyUri>()?)
|
|
|
|
/// .add_cc("https://example.com/two".parse::<XsdAnyUri>()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn add_cc<T>(&mut self, cc: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
let a = match self.object_mut().cc.take() {
|
|
|
|
Some(mut a) => {
|
|
|
|
a.add(cc.into());
|
|
|
|
a
|
|
|
|
}
|
|
|
|
None => vec![cc.into()].into(),
|
|
|
|
};
|
|
|
|
self.object_mut().cc = Some(a);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Take the cc from the current object, leaving nothing
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(cc) = video.take_cc() {
|
|
|
|
/// println!("{:?}", cc);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn take_cc(&mut self) -> Option<OneOrMany<AnyBase>> {
|
2020-05-15 03:18:34 +00:00
|
|
|
self.object_mut().cc.take()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Delete the cc from the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// # video.set_cc("https://example.com".parse::<XsdAnyUri>()?);
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// assert!(video.cc().is_some());
|
|
|
|
/// video.delete_cc();
|
|
|
|
/// assert!(video.cc().is_none());
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn delete_cc(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().cc = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Fetch the bto for the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(bto) = video.bto() {
|
|
|
|
/// println!("{:?}", bto);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn bcc<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().bcc.as_ref()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Set the bto for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of bto
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_bto("https://example.com".parse::<XsdAnyUri>()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_bcc<T>(&mut self, bcc: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
self.object_mut().bcc = Some(bcc.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Set many btos for the current object
|
|
|
|
///
|
|
|
|
/// This overwrites the contents of bto
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video.set_many_btos(vec![
|
|
|
|
/// "https://example.com/one".parse::<XsdAnyUri>()?,
|
|
|
|
/// "https://example.com/two".parse()?,
|
|
|
|
/// ]);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_many_bcc<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.object_mut().bcc = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Add a bto to the current object
|
|
|
|
///
|
|
|
|
/// This does not overwrite the contents of bto, only appends an item
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
///
|
|
|
|
/// video
|
|
|
|
/// .add_bto("https://example.com/one".parse::<XsdAnyUri>()?)
|
|
|
|
/// .add_bto("https://example.com/two".parse::<XsdAnyUri>()?);
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn add_bcc<T>(&mut self, bcc: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
let a = match self.object_mut().bcc.take() {
|
|
|
|
Some(mut a) => {
|
|
|
|
a.add(bcc.into());
|
|
|
|
a
|
|
|
|
}
|
|
|
|
None => vec![bcc.into()].into(),
|
|
|
|
};
|
|
|
|
self.object_mut().bcc = Some(a);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Take the bto from the current object, leaving nothing
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # use activitystreams_new::object::Video;
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// if let Some(bto) = video.take_bto() {
|
|
|
|
/// println!("{:?}", bto);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-05-15 22:01:29 +00:00
|
|
|
fn take_bcc(&mut self) -> Option<OneOrMany<AnyBase>> {
|
2020-05-15 03:18:34 +00:00
|
|
|
self.object_mut().bcc.take()
|
|
|
|
}
|
|
|
|
|
2020-05-16 18:11:51 +00:00
|
|
|
/// Delete the bto from the current object
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// # fn main() -> Result<(), anyhow::Error> {
|
|
|
|
/// # use activitystreams_new::{object::Video, primitives::XsdAnyUri};
|
|
|
|
/// # let mut video = Video::default();
|
|
|
|
/// # video.set_bto("https://example.com".parse::<XsdAnyUri>()?);
|
|
|
|
/// #
|
|
|
|
/// use activitystreams_new::prelude::*;
|
|
|
|
///
|
|
|
|
/// assert!(video.bto().is_some());
|
|
|
|
/// video.delete_bto();
|
|
|
|
/// assert!(video.bto().is_none());
|
|
|
|
/// # Ok(())
|
|
|
|
/// # }
|
|
|
|
/// ```
|
2020-05-15 03:18:34 +00:00
|
|
|
fn delete_bcc(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().bcc = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
pub trait ApObjectExt<Inner>: AsApObject<Inner> {
|
2020-05-15 03:18:34 +00:00
|
|
|
fn shares<'a>(&'a self) -> Option<&'a XsdAnyUri>
|
|
|
|
where
|
|
|
|
Inner: 'a,
|
|
|
|
{
|
|
|
|
self.ap_object_ref().shares.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_shares(&mut self, shares: XsdAnyUri) -> &mut Self {
|
|
|
|
self.ap_object_mut().shares = Some(shares);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_shares(&mut self) -> Option<XsdAnyUri> {
|
|
|
|
self.ap_object_mut().shares.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_shares(&mut self) -> &mut Self {
|
|
|
|
self.ap_object_mut().shares = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
fn likes<'a>(&'a self) -> Option<&'a XsdAnyUri>
|
|
|
|
where
|
|
|
|
Inner: 'a,
|
|
|
|
{
|
|
|
|
self.ap_object_ref().likes.as_ref()
|
|
|
|
}
|
|
|
|
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_likes(&mut self, likes: XsdAnyUri) -> &mut Self {
|
|
|
|
self.ap_object_mut().likes = Some(likes);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_likes(&mut self) -> Option<XsdAnyUri> {
|
|
|
|
self.ap_object_mut().likes.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_likes(&mut self) -> &mut Self {
|
|
|
|
self.ap_object_mut().likes = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
fn source<'a>(&'a self) -> Option<&'a AnyBase>
|
|
|
|
where
|
|
|
|
Inner: 'a,
|
|
|
|
{
|
|
|
|
self.ap_object_ref().source.as_ref()
|
|
|
|
}
|
|
|
|
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_source<T>(&mut self, source: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
self.ap_object_mut().source = Some(source.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
fn take_source(&mut self) -> Option<AnyBase> {
|
2020-05-15 03:18:34 +00:00
|
|
|
self.ap_object_mut().source.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_source(&mut self) -> &mut Self {
|
|
|
|
self.ap_object_mut().source = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
fn upload_media<'a>(&'a self) -> Option<&'a OneOrMany<XsdAnyUri>>
|
|
|
|
where
|
|
|
|
Inner: 'a,
|
|
|
|
{
|
|
|
|
self.ap_object_ref().upload_media.as_ref()
|
|
|
|
}
|
|
|
|
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_upload_media<T>(&mut self, upload_media: XsdAnyUri) -> &mut Self {
|
|
|
|
self.ap_object_mut().upload_media = Some(upload_media.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_many_upload_medias<I>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = XsdAnyUri>,
|
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().collect();
|
|
|
|
self.ap_object_mut().upload_media = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn add_upload_media<T>(&mut self, upload_media: XsdAnyUri) -> &mut Self {
|
|
|
|
let v = match self.ap_object_mut().upload_media.take() {
|
|
|
|
Some(mut v) => {
|
|
|
|
v.add(upload_media);
|
|
|
|
v
|
|
|
|
}
|
|
|
|
None => vec![upload_media].into(),
|
|
|
|
};
|
|
|
|
self.ap_object_mut().upload_media = Some(v);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_upload_media(&mut self) -> Option<OneOrMany<XsdAnyUri>> {
|
|
|
|
self.ap_object_mut().upload_media.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_upload_media(&mut self) -> &mut Self {
|
|
|
|
self.ap_object_mut().upload_media = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
pub trait PlaceExt: AsPlace {
|
2020-05-15 03:18:34 +00:00
|
|
|
fn accuracy(&self) -> Option<&XsdFloat> {
|
|
|
|
self.place_ref().accuracy.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_accuracy<T>(&mut self, float: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<XsdFloat>,
|
|
|
|
{
|
|
|
|
self.place_mut().accuracy = Some(float.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_accuracy(&mut self) -> Option<XsdFloat> {
|
|
|
|
self.place_mut().accuracy.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_accuracy(&mut self) -> &mut Self {
|
|
|
|
self.place_mut().accuracy = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
fn altitude(&self) -> Option<&XsdFloat> {
|
|
|
|
self.place_ref().altitude.as_ref()
|
|
|
|
}
|
|
|
|
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_altitude<T>(&mut self, float: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<XsdFloat>,
|
|
|
|
{
|
|
|
|
self.place_mut().altitude = Some(float.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_altitude(&mut self) -> Option<XsdFloat> {
|
|
|
|
self.place_mut().altitude.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_altitude(&mut self) -> &mut Self {
|
|
|
|
self.place_mut().altitude = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
fn latitude(&self) -> Option<&XsdFloat> {
|
|
|
|
self.place_ref().latitude.as_ref()
|
|
|
|
}
|
|
|
|
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_latitude<T>(&mut self, float: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<XsdFloat>,
|
|
|
|
{
|
|
|
|
self.place_mut().latitude = Some(float.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_latitude(&mut self) -> Option<XsdFloat> {
|
|
|
|
self.place_mut().latitude.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_latitude(&mut self) -> &mut Self {
|
|
|
|
self.place_mut().latitude = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
fn longitude(&self) -> Option<&XsdFloat> {
|
|
|
|
self.place_ref().longitude.as_ref()
|
|
|
|
}
|
|
|
|
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_longitude<T>(&mut self, float: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<XsdFloat>,
|
|
|
|
{
|
|
|
|
self.place_mut().longitude = Some(float.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_longitude(&mut self) -> Option<XsdFloat> {
|
|
|
|
self.place_mut().longitude.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_longitude(&mut self) -> &mut Self {
|
|
|
|
self.place_mut().longitude = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
fn radius(&self) -> Option<&XsdFloat> {
|
|
|
|
self.place_ref().radius.as_ref()
|
|
|
|
}
|
|
|
|
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_radius<T>(&mut self, float: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<XsdFloat>,
|
|
|
|
{
|
|
|
|
self.place_mut().radius = Some(float.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_radius(&mut self) -> Option<XsdFloat> {
|
|
|
|
self.place_mut().radius.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_radius(&mut self) -> &mut Self {
|
|
|
|
self.place_mut().radius = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
fn units(&self) -> Option<&Unit> {
|
|
|
|
self.place_ref().units.as_ref()
|
|
|
|
}
|
|
|
|
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_units<T>(&mut self, units: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<Unit>,
|
|
|
|
{
|
|
|
|
self.place_mut().units = Some(units.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_units(&mut self) -> Option<Unit> {
|
|
|
|
self.place_mut().units.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_units(&mut self) -> &mut Self {
|
|
|
|
self.place_mut().units = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
pub trait ProfileExt: AsProfile {
|
|
|
|
fn describes(&self) -> Option<&AnyBase> {
|
2020-05-15 03:18:34 +00:00
|
|
|
self.profile_ref().describes.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_describes<T>(&mut self, describes: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
self.profile_mut().describes = Some(describes.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
fn take_describes(&mut self) -> Option<AnyBase> {
|
2020-05-15 03:18:34 +00:00
|
|
|
self.profile_mut().describes.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_describes(&mut self) -> &mut Self {
|
|
|
|
self.profile_mut().describes = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
pub trait RelationshipExt: AsRelationship {
|
|
|
|
fn subject(&self) -> Option<&AnyBase> {
|
2020-05-15 03:18:34 +00:00
|
|
|
self.relationship_ref().subject.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_subject<T>(&mut self, subject: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
self.relationship_mut().subject = Some(subject.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
fn take_subject(&mut self) -> Option<AnyBase> {
|
2020-05-15 03:18:34 +00:00
|
|
|
self.relationship_mut().subject.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_subject(&mut self) -> &mut Self {
|
|
|
|
self.relationship_mut().subject = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
fn object(&self) -> Option<&OneOrMany<AnyBase>> {
|
|
|
|
self.relationship_ref().object.as_ref()
|
|
|
|
}
|
|
|
|
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_object<T>(&mut self, object: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
self.relationship_mut().object = Some(object.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_many_objects<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.relationship_mut().object = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn add_object<T>(&mut self, object: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
let v = match self.relationship_mut().object.take() {
|
|
|
|
Some(mut v) => {
|
|
|
|
v.add(object.into());
|
|
|
|
v
|
|
|
|
}
|
|
|
|
None => vec![object.into()].into(),
|
|
|
|
};
|
|
|
|
self.relationship_mut().object = Some(v);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
fn take_object(&mut self) -> Option<OneOrMany<AnyBase>> {
|
2020-05-15 03:18:34 +00:00
|
|
|
self.relationship_mut().object.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_object(&mut self) -> &mut Self {
|
|
|
|
self.relationship_mut().object = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
fn relationship(&self) -> Option<&OneOrMany<AnyBase>> {
|
|
|
|
self.relationship_ref().relationship.as_ref()
|
|
|
|
}
|
|
|
|
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_relationship<T>(&mut self, relationship: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
self.relationship_mut().relationship = Some(relationship.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_many_relationships<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.relationship_mut().relationship = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn add_relationship<T>(&mut self, relationship: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
let v = match self.relationship_mut().relationship.take() {
|
|
|
|
Some(mut v) => {
|
|
|
|
v.add(relationship.into());
|
|
|
|
v
|
|
|
|
}
|
|
|
|
None => vec![relationship.into()].into(),
|
|
|
|
};
|
|
|
|
self.relationship_mut().relationship = Some(v);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
fn take_relationship(&mut self) -> Option<OneOrMany<AnyBase>> {
|
2020-05-15 03:18:34 +00:00
|
|
|
self.relationship_mut().relationship.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_relationship(&mut self) -> &mut Self {
|
|
|
|
self.relationship_mut().relationship = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
pub trait TombstoneExt: AsTombstone {
|
|
|
|
fn former_type(&self) -> Option<&OneOrMany<AnyBase>> {
|
2020-05-15 03:18:34 +00:00
|
|
|
self.tombstone_ref().former_type.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_former_type<T>(&mut self, former_type: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
self.tombstone_mut().former_type = Some(former_type.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_many_former_types<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.tombstone_mut().former_type = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn add_former_type<T>(&mut self, former_type: T) -> &mut Self
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
T: Into<AnyBase>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
let v = match self.tombstone_mut().former_type.take() {
|
|
|
|
Some(mut v) => {
|
|
|
|
v.add(former_type.into());
|
|
|
|
v
|
|
|
|
}
|
|
|
|
None => vec![former_type.into()].into(),
|
|
|
|
};
|
|
|
|
self.tombstone_mut().former_type = Some(v);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
fn take_former_type(&mut self) -> Option<OneOrMany<AnyBase>> {
|
2020-05-15 03:18:34 +00:00
|
|
|
self.tombstone_mut().former_type.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_former_type(&mut self) -> &mut Self {
|
|
|
|
self.tombstone_mut().former_type = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
fn deleted(&self) -> Option<&XsdDateTime> {
|
|
|
|
self.tombstone_ref().deleted.as_ref()
|
|
|
|
}
|
|
|
|
|
2020-05-15 03:18:34 +00:00
|
|
|
fn set_deleted<T>(&mut self, deleted: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<XsdDateTime>,
|
|
|
|
{
|
|
|
|
self.tombstone_mut().deleted = Some(deleted.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_deleted(&mut self) -> Option<XsdDateTime> {
|
|
|
|
self.tombstone_mut().deleted.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_deleted(&mut self) -> &mut Self {
|
|
|
|
self.tombstone_mut().deleted = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-14 03:54:50 +00:00
|
|
|
pub type Article = Object<ArticleType>;
|
|
|
|
pub type Audio = Object<AudioType>;
|
|
|
|
pub type Document = Object<DocumentType>;
|
|
|
|
pub type Event = Object<EventType>;
|
|
|
|
pub type Image = Object<ImageType>;
|
|
|
|
pub type Note = Object<NoteType>;
|
|
|
|
pub type Page = Object<PageType>;
|
|
|
|
pub type Video = Object<VideoType>;
|
|
|
|
|
2020-05-16 17:20:34 +00:00
|
|
|
/// Define all the properties of the Object base type as described by the Activity Streams
|
|
|
|
/// vocabulary.
|
2020-05-14 16:23:38 +00:00
|
|
|
#[derive(Clone, Debug, Default, serde::Deserialize, serde::Serialize, TypedBuilder)]
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(rename_all = "camelCase")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(doc)]
|
2020-05-14 03:54:50 +00:00
|
|
|
pub struct Object<Kind> {
|
2020-05-16 17:20:34 +00:00
|
|
|
/// Identifies a resource attached or related to an object that potentially requires special
|
|
|
|
/// handling.
|
|
|
|
///
|
|
|
|
/// The intent is to provide a model that is at least semantically similar to attachments in
|
|
|
|
/// email.
|
|
|
|
///
|
|
|
|
/// - Range: Object | Link
|
|
|
|
/// - Functional: false
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
2020-05-15 22:01:29 +00:00
|
|
|
pub attachment: Option<OneOrMany<AnyBase>>,
|
2020-05-14 03:54:50 +00:00
|
|
|
|
2020-05-16 17:20:34 +00:00
|
|
|
/// Identifies one or more entities to which this object is attributed.
|
|
|
|
///
|
|
|
|
/// The attributed entities might not be Actors. For instance, an object might be attributed to
|
|
|
|
/// the completion of another activity.
|
|
|
|
///
|
|
|
|
/// - Range: Object | Link
|
|
|
|
/// - Functional: false
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
2020-05-15 22:01:29 +00:00
|
|
|
pub attributed_to: Option<OneOrMany<AnyBase>>,
|
2020-05-14 03:54:50 +00:00
|
|
|
|
2020-05-16 17:20:34 +00:00
|
|
|
/// Identifies one or more entities that represent the total population of entities for which
|
|
|
|
/// the object can considered to be relevant.
|
|
|
|
///
|
|
|
|
/// - Range: Object | Link
|
|
|
|
/// - Functional: false
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
2020-05-15 22:01:29 +00:00
|
|
|
pub audience: Option<OneOrMany<AnyBase>>,
|
2020-05-14 03:54:50 +00:00
|
|
|
|
2020-05-16 17:20:34 +00:00
|
|
|
/// The content or textual representation of the Object encoded as a JSON string.
|
|
|
|
///
|
|
|
|
/// By default, the value of content is HTML. The mediaType property can be used in the object
|
|
|
|
/// to indicate a different content type.
|
|
|
|
///
|
|
|
|
/// The content MAY be expressed using multiple language-tagged values.
|
|
|
|
///
|
|
|
|
/// - Range: xsd:string | rdf:langString
|
|
|
|
/// - Functional: false
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
2020-05-14 03:54:50 +00:00
|
|
|
pub content: Option<OneOrMany<AnyString>>,
|
|
|
|
|
2020-05-16 17:20:34 +00:00
|
|
|
/// A natural language summarization of the object encoded as HTML.
|
|
|
|
///
|
|
|
|
/// Multiple language tagged summaries MAY be provided.
|
|
|
|
///
|
|
|
|
/// - Range: xsd:string | rdf:langString
|
|
|
|
/// - Functional: false
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
2020-05-14 03:54:50 +00:00
|
|
|
pub summary: Option<OneOrMany<AnyString>>,
|
|
|
|
|
2020-05-16 17:20:34 +00:00
|
|
|
/// Identifies one or more links to representations of the object.
|
|
|
|
///
|
|
|
|
/// - Range: xsd:anyUri | Link
|
|
|
|
/// - Functional: false
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
2020-05-15 22:01:29 +00:00
|
|
|
pub url: Option<OneOrMany<AnyBase>>,
|
2020-05-14 03:54:50 +00:00
|
|
|
|
2020-05-16 17:20:34 +00:00
|
|
|
/// Identifies the entity (e.g. an application) that generated the object.
|
|
|
|
///
|
|
|
|
/// - Range: Object | Link
|
|
|
|
/// - Functional: false
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
2020-05-15 22:01:29 +00:00
|
|
|
pub generator: Option<OneOrMany<AnyBase>>,
|
2020-05-14 03:54:50 +00:00
|
|
|
|
2020-05-16 17:20:34 +00:00
|
|
|
/// Indicates an entity that describes an icon for this object.
|
|
|
|
///
|
|
|
|
/// The image should have an aspect ratio of one (horizontal) to one (vertical) and should be
|
|
|
|
/// suitable for presentation at a small size.
|
|
|
|
///
|
|
|
|
/// - Range: Image | Link
|
|
|
|
/// - Functional: false
|
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
|
|
#[builder(default, setter(strip_option, into))]
|
|
|
|
pub icon: Option<OneOrMany<AnyBase>>,
|
|
|
|
|
|
|
|
/// Indicates an entity that describes an image for this object.
|
|
|
|
///
|
|
|
|
/// Unlike the icon property, there are no aspect ratio or display size limitations assumed.
|
|
|
|
///
|
|
|
|
/// - Range: Image | Link
|
|
|
|
/// - Functional: false
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
2020-05-15 22:01:29 +00:00
|
|
|
pub image: Option<OneOrMany<AnyBase>>,
|
2020-05-14 03:54:50 +00:00
|
|
|
|
2020-05-16 17:20:34 +00:00
|
|
|
/// Indicates one or more physical or logical locations associated with the object.
|
|
|
|
///
|
|
|
|
/// - Range: Object | Link
|
|
|
|
/// - Functional: false
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
2020-05-15 22:01:29 +00:00
|
|
|
pub location: Option<OneOrMany<AnyBase>>,
|
2020-05-14 03:54:50 +00:00
|
|
|
|
2020-05-16 17:20:34 +00:00
|
|
|
/// One or more "tags" that have been associated with an objects. A tag can be any kind of Object.
|
|
|
|
///
|
|
|
|
/// The key difference between attachment and tag is that the former implies association by
|
|
|
|
/// inclusion, while the latter implies associated by reference.
|
|
|
|
///
|
|
|
|
/// - Range: Object | Link
|
|
|
|
/// - Functional: false
|
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
|
|
#[builder(default, setter(strip_option, into))]
|
|
|
|
pub tag: Option<OneOrMany<AnyBase>>,
|
|
|
|
|
|
|
|
/// The date and time describing the actual or expected starting time of the object.
|
|
|
|
///
|
|
|
|
/// When used with an Activity object, for instance, the start_time property specifies the
|
|
|
|
/// moment the activity began or is scheduled to begin.
|
|
|
|
///
|
|
|
|
/// - Range: xsd:DateTime
|
|
|
|
/// - Functional: true
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
2020-05-14 03:54:50 +00:00
|
|
|
pub start_time: Option<XsdDateTime>,
|
|
|
|
|
2020-05-16 17:20:34 +00:00
|
|
|
/// The date and time describing the actual or expected ending time of the object.
|
|
|
|
///
|
|
|
|
/// When used with an Activity object, for instance, the endTime property specifies the moment
|
|
|
|
/// the activity concluded or is expected to conclude.
|
|
|
|
///
|
|
|
|
/// - Range: xsd:dateTime
|
|
|
|
/// - Functional: true
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
2020-05-14 03:54:50 +00:00
|
|
|
pub end_time: Option<XsdDateTime>,
|
|
|
|
|
2020-05-16 17:20:34 +00:00
|
|
|
/// When the object describes a time-bound resource, such as an audio or video, a meeting, etc,
|
|
|
|
/// the duration property indicates the object's approximate duration.
|
|
|
|
///
|
|
|
|
/// The value MUST be expressed as an xsd:duration as defined by
|
|
|
|
/// [xmlschema11-2](https://www.w3.org/TR/xmlschema11-2/), section 3.3.6 (e.g. a period of 5
|
|
|
|
/// seconds is represented as "PT5S").
|
|
|
|
///
|
|
|
|
/// - Range: xsd:duration
|
|
|
|
/// - Functional: true
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option))]
|
2020-05-14 03:54:50 +00:00
|
|
|
pub duration: Option<XsdDuration>,
|
|
|
|
|
2020-05-16 17:20:34 +00:00
|
|
|
/// The date and time at which the object was published.
|
|
|
|
///
|
|
|
|
/// - Range: xsd:dateTime
|
|
|
|
/// - Functional: true
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
2020-05-14 03:54:50 +00:00
|
|
|
pub published: Option<XsdDateTime>,
|
|
|
|
|
2020-05-16 17:20:34 +00:00
|
|
|
/// The date and time at which the object was updated,
|
|
|
|
///
|
|
|
|
/// - Range: xsd:dateTime
|
|
|
|
/// - Functional: true
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
2020-05-14 03:54:50 +00:00
|
|
|
pub updated: Option<XsdDateTime>,
|
|
|
|
|
2020-05-16 17:20:34 +00:00
|
|
|
/// Indicates one or more entities for which this object is considered a response.
|
|
|
|
///
|
|
|
|
/// - Range: Object | Link
|
|
|
|
/// - Functional: false
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
2020-05-15 22:01:29 +00:00
|
|
|
pub in_reply_to: Option<OneOrMany<AnyBase>>,
|
2020-05-14 03:54:50 +00:00
|
|
|
|
2020-05-16 17:20:34 +00:00
|
|
|
/// Identifies a Collection containing objects considered to be responses to this object.
|
|
|
|
///
|
|
|
|
/// - Range: Object | Link
|
|
|
|
/// - Functional: false
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
2020-05-15 22:01:29 +00:00
|
|
|
pub replies: Option<OneOrMany<AnyBase>>,
|
2020-05-14 03:54:50 +00:00
|
|
|
|
2020-05-16 17:20:34 +00:00
|
|
|
/// Identifies an entity considered to be part of the public primary audience of an Object.
|
|
|
|
///
|
|
|
|
/// - Range: Object | Link
|
|
|
|
/// - Functional: false
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
2020-05-15 22:01:29 +00:00
|
|
|
pub to: Option<OneOrMany<AnyBase>>,
|
2020-05-14 03:54:50 +00:00
|
|
|
|
2020-05-16 17:20:34 +00:00
|
|
|
/// Identifies an Object that is part of the private primary audience of this Object.
|
|
|
|
///
|
|
|
|
/// Range: Object | Link
|
|
|
|
/// Functional: false
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
2020-05-15 22:01:29 +00:00
|
|
|
pub bto: Option<OneOrMany<AnyBase>>,
|
2020-05-14 03:54:50 +00:00
|
|
|
|
2020-05-16 17:20:34 +00:00
|
|
|
/// Identifies an Object that is part of the public secondary audience of this Object.
|
|
|
|
///
|
|
|
|
/// - Range: Object | Link
|
|
|
|
/// - Functional: false
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
2020-05-15 22:01:29 +00:00
|
|
|
pub cc: Option<OneOrMany<AnyBase>>,
|
2020-05-14 03:54:50 +00:00
|
|
|
|
2020-05-16 17:20:34 +00:00
|
|
|
/// Identifies one or more Objects that are part of the private secondary audience of this Object.
|
|
|
|
///
|
|
|
|
/// - Range: Object | Link
|
|
|
|
/// - Functional: false
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
2020-05-15 22:01:29 +00:00
|
|
|
pub bcc: Option<OneOrMany<AnyBase>>,
|
2020-05-14 03:54:50 +00:00
|
|
|
|
2020-05-16 17:20:34 +00:00
|
|
|
/// Base fields and unparsed json ends up here
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(flatten)]
|
2020-05-15 22:01:29 +00:00
|
|
|
pub inner: Base<Kind>,
|
2020-05-14 03:54:50 +00:00
|
|
|
}
|
|
|
|
|
2020-05-16 17:29:13 +00:00
|
|
|
/// Define activitypub properties for the Object type as described by the Activity Pub vocabulary.
|
2020-05-14 16:23:38 +00:00
|
|
|
#[derive(Clone, Debug, Default, serde::Deserialize, serde::Serialize, TypedBuilder)]
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(rename_all = "camelCase")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(doc)]
|
2020-05-14 03:54:50 +00:00
|
|
|
pub struct ApObject<Inner> {
|
2020-05-16 17:20:34 +00:00
|
|
|
/// This is a list of all Announce activities with this object as the object property, added as
|
|
|
|
/// a side effect.
|
|
|
|
///
|
|
|
|
/// The shares collection MUST be either an OrderedCollection or a Collection and MAY be
|
|
|
|
/// filtered on privileges of an authenticated user or as appropriate when no authentication is
|
|
|
|
/// given.
|
|
|
|
///
|
|
|
|
/// - Range: anyUri
|
|
|
|
/// - Functional: true
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option))]
|
2020-05-14 03:54:50 +00:00
|
|
|
pub shares: Option<XsdAnyUri>,
|
|
|
|
|
2020-05-16 17:20:34 +00:00
|
|
|
/// This is a list of all Like activities with this object as the object property, added as a
|
|
|
|
/// side effect.
|
|
|
|
///
|
|
|
|
/// The likes collection MUST be either an OrderedCollection or a Collection and MAY be
|
|
|
|
/// filtered on privileges of an authenticated user or as appropriate when no authentication is
|
|
|
|
/// given.
|
|
|
|
///
|
|
|
|
/// - Range: anyUri
|
|
|
|
/// - Functional: true
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option))]
|
2020-05-14 03:54:50 +00:00
|
|
|
pub likes: Option<XsdAnyUri>,
|
|
|
|
|
2020-05-16 17:20:34 +00:00
|
|
|
/// The source property is intended to convey some sort of source from which the content markup
|
|
|
|
/// was derived, as a form of provenance, or to support future editing by clients.
|
|
|
|
///
|
|
|
|
/// In general, clients do the conversion from source to content, not the other way around.
|
|
|
|
///
|
|
|
|
/// The value of source is itself an object which uses its own content and mediaType fields to
|
|
|
|
/// supply source information.
|
|
|
|
///
|
|
|
|
/// - Range: Object
|
|
|
|
/// - Functional: true
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
2020-05-15 22:01:29 +00:00
|
|
|
pub source: Option<AnyBase>,
|
2020-05-14 03:54:50 +00:00
|
|
|
|
2020-05-16 17:20:34 +00:00
|
|
|
/// Servers MAY support uploading document types to be referenced in activites, such as images,
|
|
|
|
/// video or other binary data, but the precise mechanism is out of scope for this version of
|
|
|
|
/// ActivityPub.
|
|
|
|
///
|
|
|
|
/// The Social Web Community Group is refining the protocol in the
|
|
|
|
/// [ActivityPub Media Upload report](https://www.w3.org/wiki/SocialCG/ActivityPub/MediaUpload).
|
|
|
|
///
|
|
|
|
/// - Range: anyUri
|
|
|
|
/// - Functional: false
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
2020-05-14 03:54:50 +00:00
|
|
|
pub upload_media: Option<OneOrMany<XsdAnyUri>>,
|
|
|
|
|
2020-05-16 17:20:34 +00:00
|
|
|
/// The ActivityStreams object being extended
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(flatten)]
|
|
|
|
pub inner: Inner,
|
|
|
|
}
|
|
|
|
|
2020-05-16 17:29:13 +00:00
|
|
|
/// Define all the properties of the Location type as described by the Activity Streams vocabulary.
|
|
|
|
#[derive(Clone, Debug, Default, serde::Deserialize, serde::Serialize, TypedBuilder)]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(doc)]
|
2020-05-14 03:54:50 +00:00
|
|
|
pub struct Place {
|
2020-05-16 17:29:13 +00:00
|
|
|
/// Indicates the accuracy of position coordinates on a Place objects.
|
|
|
|
///
|
|
|
|
/// Expressed in properties of percentage. e.g. "94.0"means "94.0% accurate".
|
|
|
|
///
|
|
|
|
/// - Range: xsd:float [>= 0.0f, <= 100.0f]
|
|
|
|
/// - Functional: true
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
|
|
|
pub accuracy: Option<XsdFloat>,
|
2020-05-14 03:54:50 +00:00
|
|
|
|
2020-05-16 17:29:13 +00:00
|
|
|
/// Indicates the altitude of a place. The measurement units is indicated using the units
|
|
|
|
/// property.
|
|
|
|
///
|
|
|
|
/// If units is not specified, the default is assumed to be "m" indicating meters.
|
|
|
|
///
|
|
|
|
/// - Range: xsd:float
|
|
|
|
/// - Functional: true
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
|
|
|
pub altitude: Option<XsdFloat>,
|
2020-05-14 03:54:50 +00:00
|
|
|
|
2020-05-16 17:29:13 +00:00
|
|
|
///The latitude of a place.
|
|
|
|
///
|
|
|
|
/// - Range: xsd:float
|
|
|
|
/// - Functional: true
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
|
|
|
pub latitude: Option<XsdFloat>,
|
2020-05-14 03:54:50 +00:00
|
|
|
|
2020-05-16 17:29:13 +00:00
|
|
|
/// The longitude of a place.
|
|
|
|
///
|
|
|
|
/// - Range: xsd:float
|
|
|
|
/// - Functional: true
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
|
|
|
pub longitude: Option<XsdFloat>,
|
2020-05-14 03:54:50 +00:00
|
|
|
|
2020-05-16 17:29:13 +00:00
|
|
|
/// The radius from the given latitude and longitude for a Place.
|
|
|
|
///
|
|
|
|
/// The units is expressed by the units property. If units is not specified, the default is
|
|
|
|
/// assumed to be "m" indicating meters.
|
|
|
|
///
|
|
|
|
/// - Range: xsd:float
|
|
|
|
/// - Functional: true
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
|
|
|
pub radius: Option<XsdFloat>,
|
2020-05-14 03:54:50 +00:00
|
|
|
|
2020-05-16 17:29:13 +00:00
|
|
|
/// Specifies the measurement units for the radius and altitude properties on a Place object.
|
|
|
|
///
|
|
|
|
/// If not specified, the default is assumed to be "m" for meters.
|
|
|
|
///
|
|
|
|
/// - Range: "cm" | "feet" | "inches" | "km" | "m" | xsd:anyUri | xsd:anyUri
|
|
|
|
/// - Functional: true
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option))]
|
2020-05-14 03:54:50 +00:00
|
|
|
pub units: Option<Unit>,
|
|
|
|
|
2020-05-16 17:29:13 +00:00
|
|
|
/// The object being extended
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(flatten)]
|
|
|
|
pub inner: Object<PlaceType>,
|
|
|
|
}
|
|
|
|
|
2020-05-16 17:29:13 +00:00
|
|
|
/// The object being extendedDefine all the properties of the Profile type as described by the
|
|
|
|
/// Activity Streams vocabulary.
|
|
|
|
#[derive(Clone, Debug, Default, serde::Deserialize, serde::Serialize, TypedBuilder)]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(doc)]
|
2020-05-14 03:54:50 +00:00
|
|
|
pub struct Profile {
|
2020-05-16 17:29:13 +00:00
|
|
|
/// On a Profile object, the describes property identifies the object described by the Profile.
|
|
|
|
///
|
|
|
|
/// - Range: Object
|
|
|
|
/// - Functional: true
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
2020-05-15 22:01:29 +00:00
|
|
|
pub describes: Option<AnyBase>,
|
2020-05-14 03:54:50 +00:00
|
|
|
|
2020-05-16 17:29:13 +00:00
|
|
|
/// The object being extended
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(flatten)]
|
|
|
|
pub inner: Object<ProfileType>,
|
|
|
|
}
|
|
|
|
|
2020-05-16 17:29:13 +00:00
|
|
|
/// Define all the properties of the Relationship type as described by the Activity Streams
|
|
|
|
/// vocabulary.
|
|
|
|
#[derive(Clone, Debug, Default, serde::Deserialize, serde::Serialize, TypedBuilder)]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(doc)]
|
2020-05-14 03:54:50 +00:00
|
|
|
pub struct Relationship {
|
2020-05-16 17:29:13 +00:00
|
|
|
/// On a Relationship object, the subject property identifies one of the connected individuals.
|
|
|
|
///
|
|
|
|
/// For instance, for a Relationship object describing "John is related to Sally", subject
|
|
|
|
/// would refer to John.
|
|
|
|
///
|
|
|
|
/// - Range: Object | Link
|
|
|
|
/// - Functional: true
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
2020-05-15 22:01:29 +00:00
|
|
|
pub subject: Option<AnyBase>,
|
2020-05-14 03:54:50 +00:00
|
|
|
|
2020-05-16 17:29:13 +00:00
|
|
|
/// When used within a Relationship describes the entity to which the subject is related.
|
|
|
|
///
|
|
|
|
/// - Range: Object | Link
|
|
|
|
/// - Functional: false
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
2020-05-15 22:01:29 +00:00
|
|
|
pub object: Option<OneOrMany<AnyBase>>,
|
2020-05-14 03:54:50 +00:00
|
|
|
|
2020-05-16 17:29:13 +00:00
|
|
|
/// On a Relationship object, the relationship property identifies the kind of relationship
|
|
|
|
/// that exists between subject and object.
|
|
|
|
///
|
|
|
|
/// - Range: Object
|
|
|
|
/// - Functional: false
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
2020-05-15 22:01:29 +00:00
|
|
|
pub relationship: Option<OneOrMany<AnyBase>>,
|
2020-05-14 03:54:50 +00:00
|
|
|
|
2020-05-16 17:29:13 +00:00
|
|
|
/// The object being extended
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(flatten)]
|
|
|
|
pub inner: Object<RelationshipType>,
|
|
|
|
}
|
|
|
|
|
2020-05-16 17:29:13 +00:00
|
|
|
/// Define all the properties of the Tombstone type as described by the Activity Streams
|
|
|
|
/// vocabulary.
|
|
|
|
#[derive(Clone, Debug, Default, serde::Deserialize, serde::Serialize, TypedBuilder)]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(doc)]
|
2020-05-14 03:54:50 +00:00
|
|
|
pub struct Tombstone {
|
2020-05-16 17:29:13 +00:00
|
|
|
/// On a Tombstone object, the formerType property identifies the type of the object that was
|
|
|
|
/// deleted.
|
|
|
|
///
|
|
|
|
/// - Range: Object
|
|
|
|
/// - Functional: false
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
2020-05-15 22:01:29 +00:00
|
|
|
pub former_type: Option<OneOrMany<AnyBase>>,
|
2020-05-14 03:54:50 +00:00
|
|
|
|
2020-05-16 17:29:13 +00:00
|
|
|
/// On a Tombstone object, the deleted property is a timestamp for when the object was deleted.
|
|
|
|
///
|
|
|
|
/// - Range: xsd:dateTime
|
|
|
|
/// - Functional: true
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
2020-05-14 03:54:50 +00:00
|
|
|
pub deleted: Option<XsdDateTime>,
|
|
|
|
|
2020-05-16 17:29:13 +00:00
|
|
|
/// The object being extended
|
2020-05-14 03:54:50 +00:00
|
|
|
#[serde(flatten)]
|
|
|
|
pub inner: Object<TombstoneType>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<Kind> Object<Kind> {
|
2020-05-15 22:01:29 +00:00
|
|
|
fn extending(mut base: Base<Kind>) -> Result<Self, serde_json::Error>
|
2020-05-14 16:23:38 +00:00
|
|
|
where
|
|
|
|
Kind: serde::de::DeserializeOwned,
|
|
|
|
{
|
|
|
|
Ok(Object {
|
2020-05-15 22:01:29 +00:00
|
|
|
attachment: base.remove("attachment")?,
|
|
|
|
attributed_to: base.remove("attributedTo")?,
|
|
|
|
audience: base.remove("audience")?,
|
|
|
|
content: base.remove("content")?,
|
|
|
|
summary: base.remove("summary")?,
|
|
|
|
url: base.remove("url")?,
|
|
|
|
generator: base.remove("generator")?,
|
2020-05-16 17:29:13 +00:00
|
|
|
icon: base.remove("image")?,
|
2020-05-15 22:01:29 +00:00
|
|
|
image: base.remove("image")?,
|
|
|
|
location: base.remove("location")?,
|
2020-05-16 17:29:13 +00:00
|
|
|
tag: base.remove("tag")?,
|
2020-05-15 22:01:29 +00:00
|
|
|
start_time: base.remove("startTime")?,
|
|
|
|
end_time: base.remove("endTime")?,
|
|
|
|
duration: base.remove("duration")?,
|
|
|
|
published: base.remove("published")?,
|
|
|
|
updated: base.remove("updated")?,
|
|
|
|
in_reply_to: base.remove("inReplyTo")?,
|
|
|
|
replies: base.remove("replies")?,
|
|
|
|
to: base.remove("to")?,
|
|
|
|
bto: base.remove("bto")?,
|
|
|
|
cc: base.remove("cc")?,
|
|
|
|
bcc: base.remove("bcc")?,
|
|
|
|
inner: base,
|
2020-05-14 16:23:38 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
fn retracting(self) -> Result<Base<Kind>, serde_json::Error>
|
2020-05-14 16:23:38 +00:00
|
|
|
where
|
|
|
|
Kind: serde::ser::Serialize,
|
|
|
|
{
|
|
|
|
let Object {
|
|
|
|
attachment,
|
|
|
|
attributed_to,
|
|
|
|
audience,
|
|
|
|
content,
|
|
|
|
summary,
|
|
|
|
url,
|
|
|
|
generator,
|
2020-05-16 17:29:13 +00:00
|
|
|
icon,
|
2020-05-14 16:23:38 +00:00
|
|
|
image,
|
|
|
|
location,
|
2020-05-16 17:29:13 +00:00
|
|
|
tag,
|
2020-05-14 16:23:38 +00:00
|
|
|
start_time,
|
|
|
|
end_time,
|
|
|
|
duration,
|
|
|
|
published,
|
|
|
|
updated,
|
|
|
|
in_reply_to,
|
|
|
|
replies,
|
|
|
|
to,
|
|
|
|
bto,
|
|
|
|
cc,
|
|
|
|
bcc,
|
2020-05-15 22:01:29 +00:00
|
|
|
mut inner,
|
2020-05-14 16:23:38 +00:00
|
|
|
} = self;
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
inner
|
|
|
|
.insert("attachment", attachment)?
|
|
|
|
.insert("attributedTo", attributed_to)?
|
|
|
|
.insert("audience", audience)?
|
|
|
|
.insert("content", content)?
|
|
|
|
.insert("summary", summary)?
|
|
|
|
.insert("url", url)?
|
|
|
|
.insert("generator", generator)?
|
2020-05-16 17:29:13 +00:00
|
|
|
.insert("icon", icon)?
|
2020-05-15 22:01:29 +00:00
|
|
|
.insert("image", image)?
|
|
|
|
.insert("location", location)?
|
2020-05-16 17:29:13 +00:00
|
|
|
.insert("tag", tag)?
|
2020-05-15 22:01:29 +00:00
|
|
|
.insert("startTime", start_time)?
|
|
|
|
.insert("endTime", end_time)?
|
|
|
|
.insert("duration", duration)?
|
|
|
|
.insert("published", published)?
|
|
|
|
.insert("updated", updated)?
|
|
|
|
.insert("inReplyTo", in_reply_to)?
|
|
|
|
.insert("replies", replies)?
|
|
|
|
.insert("to", to)?
|
|
|
|
.insert("bto", bto)?
|
|
|
|
.insert("cc", cc)?
|
|
|
|
.insert("bcc", bcc)?;
|
2020-05-14 03:54:50 +00:00
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
Ok(inner)
|
2020-05-14 03:54:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<Inner> ApObject<Inner> {
|
|
|
|
fn extending(mut inner: Inner) -> Result<Self, serde_json::Error>
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
Inner: UnparsedMut + markers::Object,
|
2020-05-14 03:54:50 +00:00
|
|
|
{
|
|
|
|
let shares = inner.remove("shares")?;
|
|
|
|
let likes = inner.remove("likes")?;
|
|
|
|
let source = inner.remove("source")?;
|
|
|
|
let upload_media = inner.remove("uploadMedia")?;
|
|
|
|
|
|
|
|
Ok(ApObject {
|
|
|
|
shares,
|
|
|
|
likes,
|
|
|
|
source,
|
|
|
|
upload_media,
|
|
|
|
inner,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
fn retracting(self) -> Result<Inner, serde_json::Error>
|
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
Inner: UnparsedMut + markers::Object,
|
2020-05-14 03:54:50 +00:00
|
|
|
{
|
|
|
|
let ApObject {
|
|
|
|
shares,
|
|
|
|
likes,
|
|
|
|
source,
|
|
|
|
upload_media,
|
|
|
|
mut inner,
|
|
|
|
} = self;
|
|
|
|
|
|
|
|
inner
|
|
|
|
.insert("uploadMedia", upload_media)?
|
|
|
|
.insert("source", source)?
|
|
|
|
.insert("likes", likes)?
|
|
|
|
.insert("shares", shares)?;
|
|
|
|
|
|
|
|
Ok(inner)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Place {
|
|
|
|
fn extending(mut inner: Object<PlaceType>) -> Result<Self, serde_json::Error> {
|
|
|
|
let accuracy = inner.remove("accuracy")?;
|
|
|
|
let altitude = inner.remove("altitude")?;
|
|
|
|
let latitude = inner.remove("latitude")?;
|
|
|
|
let longitude = inner.remove("longitude")?;
|
|
|
|
let radius = inner.remove("radius")?;
|
|
|
|
let units = inner.remove("units")?;
|
|
|
|
|
|
|
|
Ok(Place {
|
|
|
|
accuracy,
|
|
|
|
altitude,
|
|
|
|
latitude,
|
|
|
|
longitude,
|
|
|
|
radius,
|
|
|
|
units,
|
|
|
|
inner,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
fn retracting(self) -> Result<Object<PlaceType>, serde_json::Error> {
|
|
|
|
let Place {
|
|
|
|
accuracy,
|
|
|
|
altitude,
|
|
|
|
latitude,
|
|
|
|
longitude,
|
|
|
|
radius,
|
|
|
|
units,
|
|
|
|
mut inner,
|
|
|
|
} = self;
|
|
|
|
|
|
|
|
inner
|
|
|
|
.insert("units", units)?
|
|
|
|
.insert("radius", radius)?
|
|
|
|
.insert("longitude", longitude)?
|
|
|
|
.insert("latitude", latitude)?
|
|
|
|
.insert("altitude", altitude)?
|
|
|
|
.insert("accuracy", accuracy)?;
|
|
|
|
|
|
|
|
Ok(inner)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Profile {
|
|
|
|
fn extending(mut inner: Object<ProfileType>) -> Result<Self, serde_json::Error> {
|
|
|
|
let describes = inner.remove("describes")?;
|
|
|
|
|
|
|
|
Ok(Profile { describes, inner })
|
|
|
|
}
|
|
|
|
|
|
|
|
fn retracting(self) -> Result<Object<ProfileType>, serde_json::Error> {
|
|
|
|
let Profile {
|
|
|
|
describes,
|
|
|
|
mut inner,
|
|
|
|
} = self;
|
|
|
|
|
|
|
|
inner.insert("describes", describes)?;
|
|
|
|
Ok(inner)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Relationship {
|
|
|
|
fn extending(mut inner: Object<RelationshipType>) -> Result<Self, serde_json::Error> {
|
|
|
|
let subject = inner.remove("subject")?;
|
|
|
|
let object = inner.remove("object")?;
|
|
|
|
let relationship = inner.remove("relationship")?;
|
|
|
|
|
|
|
|
Ok(Relationship {
|
|
|
|
subject,
|
|
|
|
object,
|
|
|
|
relationship,
|
|
|
|
inner,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
fn retracting(self) -> Result<Object<RelationshipType>, serde_json::Error> {
|
|
|
|
let Relationship {
|
|
|
|
subject,
|
|
|
|
object,
|
|
|
|
relationship,
|
|
|
|
mut inner,
|
|
|
|
} = self;
|
|
|
|
|
|
|
|
inner
|
|
|
|
.insert("subject", subject)?
|
|
|
|
.insert("object", object)?
|
|
|
|
.insert("relationship", relationship)?;
|
|
|
|
|
|
|
|
Ok(inner)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Tombstone {
|
|
|
|
fn extending(mut inner: Object<TombstoneType>) -> Result<Self, serde_json::Error> {
|
|
|
|
let former_type = inner.remove("formerType")?;
|
|
|
|
let deleted = inner.remove("deleted")?;
|
|
|
|
|
|
|
|
Ok(Tombstone {
|
|
|
|
former_type,
|
|
|
|
deleted,
|
|
|
|
inner,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
fn retracting(self) -> Result<Object<TombstoneType>, serde_json::Error> {
|
|
|
|
let Tombstone {
|
|
|
|
former_type,
|
|
|
|
deleted,
|
|
|
|
mut inner,
|
|
|
|
} = self;
|
|
|
|
|
|
|
|
inner
|
|
|
|
.insert("formerType", former_type)?
|
|
|
|
.insert("deleted", deleted)?;
|
|
|
|
|
|
|
|
Ok(inner)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
impl<Kind> Extends<Kind> for Object<Kind>
|
2020-05-14 16:23:38 +00:00
|
|
|
where
|
|
|
|
Kind: serde::de::DeserializeOwned + serde::ser::Serialize,
|
|
|
|
{
|
|
|
|
type Error = serde_json::Error;
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
fn extends(base: Base<Kind>) -> Result<Self, Self::Error> {
|
|
|
|
Self::extending(base)
|
2020-05-14 16:23:38 +00:00
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
fn retracts(self) -> Result<Base<Kind>, Self::Error> {
|
2020-05-14 16:23:38 +00:00
|
|
|
self.retracting()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
impl<Kind> TryFrom<Base<Kind>> for Object<Kind>
|
2020-05-14 16:23:38 +00:00
|
|
|
where
|
|
|
|
Kind: serde::de::DeserializeOwned,
|
|
|
|
{
|
|
|
|
type Error = serde_json::Error;
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
fn try_from(base: Base<Kind>) -> Result<Self, Self::Error> {
|
|
|
|
Self::extending(base)
|
2020-05-14 16:23:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
impl<Kind> TryFrom<Object<Kind>> for Base<Kind>
|
2020-05-14 16:23:38 +00:00
|
|
|
where
|
|
|
|
Kind: serde::ser::Serialize,
|
|
|
|
{
|
|
|
|
type Error = serde_json::Error;
|
|
|
|
|
|
|
|
fn try_from(object: Object<Kind>) -> Result<Self, Self::Error> {
|
|
|
|
object.retracting()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
impl<Inner, Kind> Extends<Kind> for ApObject<Inner>
|
2020-05-14 03:54:50 +00:00
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
Inner: Extends<Kind, Error = serde_json::Error> + UnparsedMut + markers::Object,
|
|
|
|
Kind: serde::de::DeserializeOwned + serde::ser::Serialize,
|
2020-05-14 03:54:50 +00:00
|
|
|
{
|
|
|
|
type Error = serde_json::Error;
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
fn extends(base: Base<Kind>) -> Result<Self, Self::Error> {
|
|
|
|
let inner = Inner::extends(base)?;
|
2020-05-14 03:54:50 +00:00
|
|
|
Self::extending(inner)
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
fn retracts(self) -> Result<Base<Kind>, Self::Error> {
|
|
|
|
let inner = self.retracting()?;
|
|
|
|
inner.retracts()
|
2020-05-14 03:54:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
impl Extends<PlaceType> for Place {
|
2020-05-14 03:54:50 +00:00
|
|
|
type Error = serde_json::Error;
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
fn extends(base: Base<PlaceType>) -> Result<Self, Self::Error> {
|
|
|
|
let inner = Object::extends(base)?;
|
|
|
|
Self::extending(inner)
|
2020-05-14 03:54:50 +00:00
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
fn retracts(self) -> Result<Base<PlaceType>, Self::Error> {
|
|
|
|
let inner = self.retracting()?;
|
|
|
|
inner.retracts()
|
2020-05-14 03:54:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl TryFrom<Object<PlaceType>> for Place {
|
|
|
|
type Error = serde_json::Error;
|
|
|
|
|
|
|
|
fn try_from(object: Object<PlaceType>) -> Result<Self, Self::Error> {
|
|
|
|
Self::extending(object)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-14 16:23:38 +00:00
|
|
|
impl TryFrom<Place> for Object<PlaceType> {
|
|
|
|
type Error = serde_json::Error;
|
|
|
|
|
|
|
|
fn try_from(place: Place) -> Result<Self, Self::Error> {
|
|
|
|
place.retracting()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
impl Extends<ProfileType> for Profile {
|
2020-05-14 03:54:50 +00:00
|
|
|
type Error = serde_json::Error;
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
fn extends(base: Base<ProfileType>) -> Result<Self, Self::Error> {
|
|
|
|
let inner = Object::extends(base)?;
|
|
|
|
Self::extending(inner)
|
2020-05-14 03:54:50 +00:00
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
fn retracts(self) -> Result<Base<ProfileType>, Self::Error> {
|
|
|
|
let inner = self.retracting()?;
|
|
|
|
inner.retracts()
|
2020-05-14 03:54:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl TryFrom<Object<ProfileType>> for Profile {
|
|
|
|
type Error = serde_json::Error;
|
|
|
|
|
|
|
|
fn try_from(object: Object<ProfileType>) -> Result<Self, Self::Error> {
|
|
|
|
Self::extending(object)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-14 16:23:38 +00:00
|
|
|
impl TryFrom<Profile> for Object<ProfileType> {
|
|
|
|
type Error = serde_json::Error;
|
|
|
|
|
|
|
|
fn try_from(profile: Profile) -> Result<Self, Self::Error> {
|
|
|
|
profile.retracting()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
impl Extends<RelationshipType> for Relationship {
|
2020-05-14 03:54:50 +00:00
|
|
|
type Error = serde_json::Error;
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
fn extends(base: Base<RelationshipType>) -> Result<Self, Self::Error> {
|
|
|
|
let inner = Object::extends(base)?;
|
|
|
|
Self::extending(inner)
|
2020-05-14 03:54:50 +00:00
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
fn retracts(self) -> Result<Base<RelationshipType>, Self::Error> {
|
|
|
|
let inner = self.retracting()?;
|
|
|
|
inner.retracts()
|
2020-05-14 03:54:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl TryFrom<Object<RelationshipType>> for Relationship {
|
|
|
|
type Error = serde_json::Error;
|
|
|
|
|
|
|
|
fn try_from(object: Object<RelationshipType>) -> Result<Self, Self::Error> {
|
|
|
|
Self::extending(object)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-14 16:23:38 +00:00
|
|
|
impl TryFrom<Relationship> for Object<RelationshipType> {
|
|
|
|
type Error = serde_json::Error;
|
|
|
|
|
|
|
|
fn try_from(relationship: Relationship) -> Result<Self, Self::Error> {
|
|
|
|
relationship.retracting()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
impl Extends<TombstoneType> for Tombstone {
|
2020-05-14 03:54:50 +00:00
|
|
|
type Error = serde_json::Error;
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
fn extends(base: Base<TombstoneType>) -> Result<Self, Self::Error> {
|
|
|
|
let inner = Object::extends(base)?;
|
|
|
|
Self::extending(inner)
|
2020-05-14 03:54:50 +00:00
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
fn retracts(self) -> Result<Base<TombstoneType>, Self::Error> {
|
|
|
|
let inner = self.retracting()?;
|
|
|
|
inner.retracts()
|
2020-05-14 03:54:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl TryFrom<Object<TombstoneType>> for Tombstone {
|
|
|
|
type Error = serde_json::Error;
|
|
|
|
|
|
|
|
fn try_from(object: Object<TombstoneType>) -> Result<Self, Self::Error> {
|
|
|
|
Self::extending(object)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-14 16:23:38 +00:00
|
|
|
impl TryFrom<Tombstone> for Object<TombstoneType> {
|
|
|
|
type Error = serde_json::Error;
|
|
|
|
|
|
|
|
fn try_from(tombstone: Tombstone) -> Result<Self, Self::Error> {
|
|
|
|
tombstone.retracting()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 03:18:34 +00:00
|
|
|
impl<Kind> UnparsedMut for Object<Kind> {
|
2020-05-14 03:54:50 +00:00
|
|
|
fn unparsed_mut(&mut self) -> &mut Unparsed {
|
2020-05-15 22:01:29 +00:00
|
|
|
self.inner.unparsed_mut()
|
2020-05-14 03:54:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 03:18:34 +00:00
|
|
|
impl<Inner> UnparsedMut for ApObject<Inner>
|
2020-05-14 03:54:50 +00:00
|
|
|
where
|
2020-05-15 03:18:34 +00:00
|
|
|
Inner: UnparsedMut,
|
2020-05-14 03:54:50 +00:00
|
|
|
{
|
|
|
|
fn unparsed_mut(&mut self) -> &mut Unparsed {
|
|
|
|
self.inner.unparsed_mut()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 03:18:34 +00:00
|
|
|
impl UnparsedMut for Place {
|
2020-05-14 03:54:50 +00:00
|
|
|
fn unparsed_mut(&mut self) -> &mut Unparsed {
|
|
|
|
self.inner.unparsed_mut()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 03:18:34 +00:00
|
|
|
impl UnparsedMut for Profile {
|
2020-05-14 03:54:50 +00:00
|
|
|
fn unparsed_mut(&mut self) -> &mut Unparsed {
|
|
|
|
self.inner.unparsed_mut()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 03:18:34 +00:00
|
|
|
impl UnparsedMut for Relationship {
|
2020-05-14 03:54:50 +00:00
|
|
|
fn unparsed_mut(&mut self) -> &mut Unparsed {
|
|
|
|
self.inner.unparsed_mut()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 03:18:34 +00:00
|
|
|
impl UnparsedMut for Tombstone {
|
2020-05-14 03:54:50 +00:00
|
|
|
fn unparsed_mut(&mut self) -> &mut Unparsed {
|
|
|
|
self.inner.unparsed_mut()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
impl<Kind> markers::Base for Object<Kind> {}
|
|
|
|
impl<Kind> markers::Object for Object<Kind> {}
|
2020-05-15 03:18:34 +00:00
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
impl<Inner> markers::Base for ApObject<Inner> where Inner: markers::Base {}
|
|
|
|
impl<Inner> markers::Object for ApObject<Inner> where Inner: markers::Object {}
|
2020-05-15 03:18:34 +00:00
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
impl markers::Base for Place {}
|
|
|
|
impl markers::Object for Place {}
|
2020-05-15 03:18:34 +00:00
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
impl markers::Base for Profile {}
|
|
|
|
impl markers::Object for Profile {}
|
2020-05-15 03:18:34 +00:00
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
impl markers::Base for Relationship {}
|
|
|
|
impl markers::Object for Relationship {}
|
2020-05-15 03:18:34 +00:00
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
impl markers::Base for Tombstone {}
|
|
|
|
impl markers::Object for Tombstone {}
|
2020-05-15 03:18:34 +00:00
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
impl<T, Kind> ObjectExt<Kind> for T where T: AsObject<Kind> {}
|
|
|
|
impl<T, Inner> ApObjectExt<Inner> for T where T: AsApObject<Inner> {}
|
|
|
|
impl<T> PlaceExt for T where T: AsPlace {}
|
|
|
|
impl<T> ProfileExt for T where T: AsProfile {}
|
|
|
|
impl<T> RelationshipExt for T where T: AsRelationship {}
|
|
|
|
impl<T> TombstoneExt for T where T: AsTombstone {}
|
2020-05-15 03:18:34 +00:00
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
impl<Kind> AsBase<Kind> for Object<Kind> {
|
|
|
|
fn base_ref(&self) -> &Base<Kind> {
|
|
|
|
&self.inner
|
|
|
|
}
|
2020-05-15 03:18:34 +00:00
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
fn base_mut(&mut self) -> &mut Base<Kind> {
|
|
|
|
&mut self.inner
|
|
|
|
}
|
|
|
|
}
|
2020-05-15 03:18:34 +00:00
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
impl<Kind> AsObject<Kind> for Object<Kind> {
|
2020-05-15 03:18:34 +00:00
|
|
|
fn object_ref(&self) -> &Object<Kind> {
|
|
|
|
self
|
|
|
|
}
|
2020-05-15 22:01:29 +00:00
|
|
|
|
2020-05-15 03:18:34 +00:00
|
|
|
fn object_mut(&mut self) -> &mut Object<Kind> {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
impl<Inner, Kind> AsBase<Kind> for ApObject<Inner>
|
2020-05-15 03:18:34 +00:00
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
Inner: AsBase<Kind>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
2020-05-15 22:01:29 +00:00
|
|
|
fn base_ref(&self) -> &Base<Kind> {
|
|
|
|
self.inner.base_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn base_mut(&mut self) -> &mut Base<Kind> {
|
|
|
|
self.inner.base_mut()
|
2020-05-15 03:18:34 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-15 22:01:29 +00:00
|
|
|
|
|
|
|
impl<Inner, Kind> AsObject<Kind> for ApObject<Inner>
|
2020-05-15 03:18:34 +00:00
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
Inner: AsObject<Kind>,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
2020-05-15 22:01:29 +00:00
|
|
|
fn object_ref(&self) -> &Object<Kind> {
|
|
|
|
self.inner.object_ref()
|
|
|
|
}
|
|
|
|
|
2020-05-15 03:18:34 +00:00
|
|
|
fn object_mut(&mut self) -> &mut Object<Kind> {
|
|
|
|
self.inner.object_mut()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
impl<Inner> AsApObject<Inner> for ApObject<Inner>
|
2020-05-15 03:18:34 +00:00
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
Inner: markers::Object,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
fn ap_object_ref(&self) -> &ApObject<Inner> {
|
|
|
|
self
|
|
|
|
}
|
2020-05-15 22:01:29 +00:00
|
|
|
|
2020-05-15 03:18:34 +00:00
|
|
|
fn ap_object_mut(&mut self) -> &mut ApObject<Inner> {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
impl<Inner> AsPlace for ApObject<Inner>
|
2020-05-15 03:18:34 +00:00
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
Inner: AsPlace,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
fn place_ref(&self) -> &Place {
|
|
|
|
self.inner.place_ref()
|
|
|
|
}
|
2020-05-15 22:01:29 +00:00
|
|
|
|
2020-05-15 03:18:34 +00:00
|
|
|
fn place_mut(&mut self) -> &mut Place {
|
|
|
|
self.inner.place_mut()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
impl<Inner> AsProfile for ApObject<Inner>
|
2020-05-15 03:18:34 +00:00
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
Inner: AsProfile,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
fn profile_ref(&self) -> &Profile {
|
|
|
|
self.inner.profile_ref()
|
|
|
|
}
|
2020-05-15 22:01:29 +00:00
|
|
|
|
2020-05-15 03:18:34 +00:00
|
|
|
fn profile_mut(&mut self) -> &mut Profile {
|
|
|
|
self.inner.profile_mut()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
impl<Inner> AsRelationship for ApObject<Inner>
|
2020-05-15 03:18:34 +00:00
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
Inner: AsRelationship,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
fn relationship_ref(&self) -> &Relationship {
|
|
|
|
self.inner.relationship_ref()
|
|
|
|
}
|
2020-05-15 22:01:29 +00:00
|
|
|
|
2020-05-15 03:18:34 +00:00
|
|
|
fn relationship_mut(&mut self) -> &mut Relationship {
|
|
|
|
self.inner.relationship_mut()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
impl<Inner> AsTombstone for ApObject<Inner>
|
2020-05-15 03:18:34 +00:00
|
|
|
where
|
2020-05-15 22:01:29 +00:00
|
|
|
Inner: AsTombstone,
|
2020-05-15 03:18:34 +00:00
|
|
|
{
|
|
|
|
fn tombstone_ref(&self) -> &Tombstone {
|
|
|
|
self.inner.tombstone_ref()
|
|
|
|
}
|
2020-05-15 22:01:29 +00:00
|
|
|
|
2020-05-15 03:18:34 +00:00
|
|
|
fn tombstone_mut(&mut self) -> &mut Tombstone {
|
|
|
|
self.inner.tombstone_mut()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
impl AsBase<PlaceType> for Place {
|
|
|
|
fn base_ref(&self) -> &Base<PlaceType> {
|
|
|
|
self.inner.base_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn base_mut(&mut self) -> &mut Base<PlaceType> {
|
|
|
|
self.inner.base_mut()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl AsObject<PlaceType> for Place {
|
|
|
|
fn object_ref(&self) -> &Object<PlaceType> {
|
|
|
|
&self.inner
|
|
|
|
}
|
|
|
|
|
|
|
|
fn object_mut(&mut self) -> &mut Object<PlaceType> {
|
|
|
|
&mut self.inner
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl AsPlace for Place {
|
2020-05-15 03:18:34 +00:00
|
|
|
fn place_ref(&self) -> &Place {
|
|
|
|
self
|
|
|
|
}
|
2020-05-15 22:01:29 +00:00
|
|
|
|
2020-05-15 03:18:34 +00:00
|
|
|
fn place_mut(&mut self) -> &mut Place {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
impl AsBase<ProfileType> for Profile {
|
|
|
|
fn base_ref(&self) -> &Base<ProfileType> {
|
|
|
|
self.inner.base_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn base_mut(&mut self) -> &mut Base<ProfileType> {
|
|
|
|
self.inner.base_mut()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl AsObject<ProfileType> for Profile {
|
|
|
|
fn object_ref(&self) -> &Object<ProfileType> {
|
|
|
|
&self.inner
|
|
|
|
}
|
|
|
|
|
|
|
|
fn object_mut(&mut self) -> &mut Object<ProfileType> {
|
|
|
|
&mut self.inner
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl AsProfile for Profile {
|
2020-05-15 03:18:34 +00:00
|
|
|
fn profile_ref(&self) -> &Profile {
|
|
|
|
self
|
|
|
|
}
|
2020-05-15 22:01:29 +00:00
|
|
|
|
2020-05-15 03:18:34 +00:00
|
|
|
fn profile_mut(&mut self) -> &mut Profile {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
impl AsBase<RelationshipType> for Relationship {
|
|
|
|
fn base_ref(&self) -> &Base<RelationshipType> {
|
|
|
|
self.inner.base_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn base_mut(&mut self) -> &mut Base<RelationshipType> {
|
|
|
|
self.inner.base_mut()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl AsObject<RelationshipType> for Relationship {
|
|
|
|
fn object_ref(&self) -> &Object<RelationshipType> {
|
|
|
|
&self.inner
|
|
|
|
}
|
|
|
|
|
|
|
|
fn object_mut(&mut self) -> &mut Object<RelationshipType> {
|
|
|
|
&mut self.inner
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl AsRelationship for Relationship {
|
2020-05-15 03:18:34 +00:00
|
|
|
fn relationship_ref(&self) -> &Relationship {
|
|
|
|
self
|
|
|
|
}
|
2020-05-15 22:01:29 +00:00
|
|
|
|
2020-05-15 03:18:34 +00:00
|
|
|
fn relationship_mut(&mut self) -> &mut Relationship {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:01:29 +00:00
|
|
|
impl AsBase<TombstoneType> for Tombstone {
|
|
|
|
fn base_ref(&self) -> &Base<TombstoneType> {
|
|
|
|
self.inner.base_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn base_mut(&mut self) -> &mut Base<TombstoneType> {
|
|
|
|
self.inner.base_mut()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl AsObject<TombstoneType> for Tombstone {
|
|
|
|
fn object_ref(&self) -> &Object<TombstoneType> {
|
|
|
|
&self.inner
|
|
|
|
}
|
|
|
|
|
|
|
|
fn object_mut(&mut self) -> &mut Object<TombstoneType> {
|
|
|
|
&mut self.inner
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl AsTombstone for Tombstone {
|
2020-05-15 03:18:34 +00:00
|
|
|
fn tombstone_ref(&self) -> &Tombstone {
|
|
|
|
self
|
|
|
|
}
|
2020-05-15 22:01:29 +00:00
|
|
|
|
2020-05-15 03:18:34 +00:00
|
|
|
fn tombstone_mut(&mut self) -> &mut Tombstone {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|