2020-05-14 03:54:50 +00:00
|
|
|
use crate::{
|
|
|
|
either::Either,
|
|
|
|
primitives::{
|
|
|
|
AnyString, MimeMediaType, OneOrMany, Unit, Unparsed, XsdAnyUri, XsdDateTime, XsdDuration,
|
2020-05-14 16:23:38 +00:00
|
|
|
XsdFloat, XsdString,
|
2020-05-14 03:54:50 +00:00
|
|
|
},
|
2020-05-15 03:18:34 +00:00
|
|
|
traits::{self, Extends, 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 03:18:34 +00:00
|
|
|
pub trait ObjectRef<Kind>: traits::Object {
|
|
|
|
fn object_ref(&self) -> &Object<Kind>;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait ObjectMut<Kind>: traits::Object {
|
|
|
|
fn object_mut(&mut self) -> &mut Object<Kind>;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait ApObjectRef<Inner>: traits::Object {
|
|
|
|
fn ap_object_ref(&self) -> &ApObject<Inner>;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait ApObjectMut<Inner>: traits::Object {
|
|
|
|
fn ap_object_mut(&mut self) -> &mut ApObject<Inner>;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait PlaceRef: traits::Object {
|
|
|
|
fn place_ref(&self) -> &Place;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait PlaceMut: traits::Object {
|
|
|
|
fn place_mut(&mut self) -> &mut Place;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait ProfileRef: traits::Object {
|
|
|
|
fn profile_ref(&self) -> &Profile;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait ProfileMut: traits::Object {
|
|
|
|
fn profile_mut(&mut self) -> &mut Profile;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait RelationshipRef: traits::Object {
|
|
|
|
fn relationship_ref(&self) -> &Relationship;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait RelationshipMut: traits::Object {
|
|
|
|
fn relationship_mut(&mut self) -> &mut Relationship;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait TombstoneRef: traits::Object {
|
|
|
|
fn tombstone_ref(&self) -> &Tombstone;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait TombstoneMut: traits::Object {
|
|
|
|
fn tombstone_mut(&mut self) -> &mut Tombstone;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait ObjectRefExt<Kind>: ObjectRef<Kind> {
|
|
|
|
fn context<'a>(&'a self) -> Option<&'a OneOrMany<AnyObject>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().context.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn id<'a>(&'a self) -> Option<&'a XsdAnyUri>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().id.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn kind<'a>(&'a self) -> Option<&'a Kind>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().kind.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn attachment<'a>(&'a self) -> Option<&'a OneOrMany<AnyObject>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().attachment.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn attributed_to<'a>(&'a self) -> Option<&'a OneOrMany<AnyObject>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().attributed_to.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn audience<'a>(&'a self) -> Option<&'a OneOrMany<AnyObject>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().audience.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn content<'a>(&'a self) -> Option<&'a OneOrMany<AnyString>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().content.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn name<'a>(&'a self) -> Option<&'a OneOrMany<AnyString>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().name.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn summary<'a>(&'a self) -> Option<&'a OneOrMany<AnyString>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().summary.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn url<'a>(&'a self) -> Option<&'a OneOrMany<AnyObject>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().url.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn media_type<'a>(&'a self) -> Option<&'a MimeMediaType>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().media_type.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn generator<'a>(&'a self) -> Option<&'a OneOrMany<AnyObject>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().generator.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn image<'a>(&'a self) -> Option<&'a OneOrMany<AnyObject>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().image.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn location<'a>(&'a self) -> Option<&'a OneOrMany<AnyObject>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().location.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn preview<'a>(&'a self) -> Option<&'a OneOrMany<AnyObject>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().preview.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn start_time<'a>(&'a self) -> Option<&'a XsdDateTime>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().start_time.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn end_time<'a>(&'a self) -> Option<&'a XsdDateTime>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().end_time.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn duration<'a>(&'a self) -> Option<&'a XsdDuration>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().duration.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn published<'a>(&'a self) -> Option<&'a XsdDateTime>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().published.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn updated<'a>(&'a self) -> Option<&'a XsdDateTime>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().updated.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn in_reply_to<'a>(&'a self) -> Option<&'a OneOrMany<AnyObject>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().in_reply_to.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn replies<'a>(&'a self) -> Option<&'a OneOrMany<AnyObject>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().replies.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn to<'a>(&'a self) -> Option<&'a OneOrMany<AnyObject>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().to.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn bto<'a>(&'a self) -> Option<&'a OneOrMany<AnyObject>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().bto.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn cc<'a>(&'a self) -> Option<&'a OneOrMany<AnyObject>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().cc.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn bcc<'a>(&'a self) -> Option<&'a OneOrMany<AnyObject>>
|
|
|
|
where
|
|
|
|
Kind: 'a,
|
|
|
|
{
|
|
|
|
self.object_ref().bcc.as_ref()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait ObjectMutExt<Kind>: ObjectMut<Kind> {
|
|
|
|
fn set_context<T>(&mut self, context: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
self.object_mut().context = Some(context.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_many_contexts<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.object_mut().context = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn add_context<T>(&mut self, context: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
let c = match self.object_mut().context.take() {
|
|
|
|
Some(mut c) => {
|
|
|
|
c.add(context.into());
|
|
|
|
c
|
|
|
|
}
|
|
|
|
None => vec![context.into()].into(),
|
|
|
|
};
|
|
|
|
self.object_mut().context = Some(c);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_context(&mut self) -> Option<OneOrMany<AnyObject>> {
|
|
|
|
self.object_mut().context.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_context(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().context = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_id(&mut self, id: XsdAnyUri) -> &mut Self {
|
|
|
|
self.object_mut().id = Some(id);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_id(&mut self) -> Option<XsdAnyUri> {
|
|
|
|
self.object_mut().id.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_id(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().id = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_kind(&mut self, kind: Kind) -> &mut Self {
|
|
|
|
self.object_mut().kind = Some(kind);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_kind(&mut self) -> Option<Kind> {
|
|
|
|
self.object_mut().kind.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_kind(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().kind = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_attachment<T>(&mut self, attachment: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
self.object_mut().attachment = Some(attachment.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_many_attachments<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.object_mut().attachment = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn add_attachment<T>(&mut self, attachment: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_attachment(&mut self) -> Option<OneOrMany<AnyObject>> {
|
|
|
|
self.object_mut().attachment.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_attachment(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().attachment = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_attributed_to<T>(&mut self, attributed_to: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
self.object_mut().attributed_to = Some(attributed_to.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_many_attributed_tos<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.object_mut().attributed_to = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn add_attributed_to<T>(&mut self, attributed_to: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_attributed_to(&mut self) -> Option<OneOrMany<AnyObject>> {
|
|
|
|
self.object_mut().attributed_to.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_attributed_to(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().attributed_to = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_audience<T>(&mut self, audience: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
self.object_mut().audience = Some(audience.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_many_audiences<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.object_mut().audience = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn add_audience<T>(&mut self, audience: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_audience(&mut self) -> Option<OneOrMany<AnyObject>> {
|
|
|
|
self.object_mut().audience.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_audience(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().audience = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_content<T>(&mut self, content: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyString>,
|
|
|
|
{
|
|
|
|
self.object_mut().content = Some(content.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_content(&mut self) -> Option<OneOrMany<AnyString>> {
|
|
|
|
self.object_mut().content.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_content(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().content = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_name<T>(&mut self, name: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyString>,
|
|
|
|
{
|
|
|
|
self.object_mut().name = Some(name.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_many_names<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().name = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn add_name<T>(&mut self, name: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyString>,
|
|
|
|
{
|
|
|
|
let a = match self.object_mut().name.take() {
|
|
|
|
Some(mut a) => {
|
|
|
|
a.add(name.into());
|
|
|
|
a
|
|
|
|
}
|
|
|
|
None => vec![name.into()].into(),
|
|
|
|
};
|
|
|
|
self.object_mut().name = Some(a);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_name(&mut self) -> Option<OneOrMany<AnyString>> {
|
|
|
|
self.object_mut().name.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_name(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().name = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_summary<T>(&mut self, summary: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyString>,
|
|
|
|
{
|
|
|
|
self.object_mut().summary = Some(summary.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_many_summarys<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().summary = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_summary(&mut self) -> Option<OneOrMany<AnyString>> {
|
|
|
|
self.object_mut().summary.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_summary(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().summary = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_url<T>(&mut self, url: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
self.object_mut().url = Some(url.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_many_urls<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.object_mut().url = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn add_url<T>(&mut self, url: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_url(&mut self) -> Option<OneOrMany<AnyObject>> {
|
|
|
|
self.object_mut().url.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_url(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().url = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_media_type(&mut self, media_type: MimeMediaType) -> &mut Self {
|
|
|
|
self.object_mut().media_type = Some(media_type);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_media_type(&mut self) -> Option<MimeMediaType> {
|
|
|
|
self.object_mut().media_type.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_media_type(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().media_type = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_generator<T>(&mut self, generator: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
self.object_mut().generator = Some(generator.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_many_generators<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.object_mut().generator = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn add_generator<T>(&mut self, generator: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_generator(&mut self) -> Option<OneOrMany<AnyObject>> {
|
|
|
|
self.object_mut().generator.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_generator(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().generator = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_image<T>(&mut self, image: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
self.object_mut().image = Some(image.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_many_images<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.object_mut().image = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn add_image<T>(&mut self, image: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_image(&mut self) -> Option<OneOrMany<AnyObject>> {
|
|
|
|
self.object_mut().image.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_image(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().image = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_location<T>(&mut self, location: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
self.object_mut().location = Some(location.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_many_locations<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.object_mut().location = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn add_location<T>(&mut self, location: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_location(&mut self) -> Option<OneOrMany<AnyObject>> {
|
|
|
|
self.object_mut().location.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_location(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().location = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_preview<T>(&mut self, preview: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
self.object_mut().preview = Some(preview.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_many_previews<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.object_mut().preview = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn add_preview<T>(&mut self, preview: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
let a = match self.object_mut().preview.take() {
|
|
|
|
Some(mut a) => {
|
|
|
|
a.add(preview.into());
|
|
|
|
a
|
|
|
|
}
|
|
|
|
None => vec![preview.into()].into(),
|
|
|
|
};
|
|
|
|
self.object_mut().preview = Some(a);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_preview(&mut self) -> Option<OneOrMany<AnyObject>> {
|
|
|
|
self.object_mut().preview.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_preview(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().preview = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_start_time(&mut self, start_time: XsdDateTime) -> &mut Self {
|
|
|
|
self.object_mut().start_time = Some(start_time);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_start_time(&mut self) -> Option<XsdDateTime> {
|
|
|
|
self.object_mut().start_time.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_start_time(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().start_time = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_end_time(&mut self, end_time: XsdDateTime) -> &mut Self {
|
|
|
|
self.object_mut().end_time = Some(end_time);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_end_time(&mut self) -> Option<XsdDateTime> {
|
|
|
|
self.object_mut().end_time.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_end_time(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().end_time = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_duration(&mut self, duration: XsdDuration) -> &mut Self {
|
|
|
|
self.object_mut().duration = Some(duration);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_duration(&mut self) -> Option<XsdDuration> {
|
|
|
|
self.object_mut().duration.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_duration(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().duration = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_published(&mut self, published: XsdDateTime) -> &mut Self {
|
|
|
|
self.object_mut().published = Some(published);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_published(&mut self) -> Option<XsdDateTime> {
|
|
|
|
self.object_mut().published.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_published(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().published = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_updated(&mut self, updated: XsdDateTime) -> &mut Self {
|
|
|
|
self.object_mut().updated = Some(updated);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_updated(&mut self) -> Option<XsdDateTime> {
|
|
|
|
self.object_mut().updated.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_updated(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().updated = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_in_reply_to<T>(&mut self, in_reply_to: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
self.object_mut().in_reply_to = Some(in_reply_to.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_many_in_reply_tos<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.object_mut().in_reply_to = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn add_in_reply_to<T>(&mut self, in_reply_to: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_in_reply_to(&mut self) -> Option<OneOrMany<AnyObject>> {
|
|
|
|
self.object_mut().in_reply_to.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_in_reply_to(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().in_reply_to = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_replies<T>(&mut self, replies: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
self.object_mut().replies = Some(replies.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_many_repliess<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.object_mut().replies = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn add_replies<T>(&mut self, replies: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_replies(&mut self) -> Option<OneOrMany<AnyObject>> {
|
|
|
|
self.object_mut().replies.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_replies(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().replies = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_to<T>(&mut self, to: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
self.object_mut().to = Some(to.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_many_tos<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.object_mut().to = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn add_to<T>(&mut self, to: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_to(&mut self) -> Option<OneOrMany<AnyObject>> {
|
|
|
|
self.object_mut().to.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_to(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().to = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_bto<T>(&mut self, bto: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
self.object_mut().bto = Some(bto.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_many_btos<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.object_mut().bto = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn add_bto<T>(&mut self, bto: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_bto(&mut self) -> Option<OneOrMany<AnyObject>> {
|
|
|
|
self.object_mut().bto.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_bto(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().bto = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_cc<T>(&mut self, cc: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
self.object_mut().cc = Some(cc.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_many_ccs<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.object_mut().cc = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn add_cc<T>(&mut self, cc: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_cc(&mut self) -> Option<OneOrMany<AnyObject>> {
|
|
|
|
self.object_mut().cc.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_cc(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().cc = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_bcc<T>(&mut self, bcc: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
self.object_mut().bcc = Some(bcc.into().into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_many_bcc<I, T>(&mut self, items: I) -> &mut Self
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = T>,
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
let v: Vec<_> = items.into_iter().map(Into::into).collect();
|
|
|
|
self.object_mut().bcc = Some(v.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn add_bcc<T>(&mut self, bcc: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_bcc(&mut self) -> Option<OneOrMany<AnyObject>> {
|
|
|
|
self.object_mut().bcc.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_bcc(&mut self) -> &mut Self {
|
|
|
|
self.object_mut().bcc = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait ApObjectRefExt<Inner>: ApObjectRef<Inner> {
|
|
|
|
fn shares<'a>(&'a self) -> Option<&'a XsdAnyUri>
|
|
|
|
where
|
|
|
|
Inner: 'a,
|
|
|
|
{
|
|
|
|
self.ap_object_ref().shares.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn likes<'a>(&'a self) -> Option<&'a XsdAnyUri>
|
|
|
|
where
|
|
|
|
Inner: 'a,
|
|
|
|
{
|
|
|
|
self.ap_object_ref().likes.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn source<'a>(&'a self) -> Option<&'a AnyObject>
|
|
|
|
where
|
|
|
|
Inner: 'a,
|
|
|
|
{
|
|
|
|
self.ap_object_ref().source.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn upload_media<'a>(&'a self) -> Option<&'a OneOrMany<XsdAnyUri>>
|
|
|
|
where
|
|
|
|
Inner: 'a,
|
|
|
|
{
|
|
|
|
self.ap_object_ref().upload_media.as_ref()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait ApObjectMutExt<Inner>: ApObjectMut<Inner> {
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_source<T>(&mut self, source: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
self.ap_object_mut().source = Some(source.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_source(&mut self) -> Option<AnyObject> {
|
|
|
|
self.ap_object_mut().source.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_source(&mut self) -> &mut Self {
|
|
|
|
self.ap_object_mut().source = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait PlaceRefExt: PlaceRef {
|
|
|
|
fn accuracy(&self) -> Option<&XsdFloat> {
|
|
|
|
self.place_ref().accuracy.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn altitude(&self) -> Option<&XsdFloat> {
|
|
|
|
self.place_ref().altitude.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn latitude(&self) -> Option<&XsdFloat> {
|
|
|
|
self.place_ref().latitude.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn longitude(&self) -> Option<&XsdFloat> {
|
|
|
|
self.place_ref().longitude.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn units(&self) -> Option<&Unit> {
|
|
|
|
self.place_ref().units.as_ref()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait PlaceMutExt: PlaceMut {
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait ProfileRefExt: ProfileRef {
|
|
|
|
fn describes(&self) -> Option<&AnyObject> {
|
|
|
|
self.profile_ref().describes.as_ref()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait ProfileMutExt: ProfileMut {
|
|
|
|
fn set_describes<T>(&mut self, describes: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
self.profile_mut().describes = Some(describes.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_describes(&mut self) -> Option<AnyObject> {
|
|
|
|
self.profile_mut().describes.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_describes(&mut self) -> &mut Self {
|
|
|
|
self.profile_mut().describes = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait RelationshipRefExt: RelationshipRef {
|
|
|
|
fn subject(&self) -> Option<&AnyObject> {
|
|
|
|
self.relationship_ref().subject.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn object(&self) -> Option<&OneOrMany<AnyObject>> {
|
|
|
|
self.relationship_ref().object.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn relationship(&self) -> Option<&OneOrMany<AnyObject>> {
|
|
|
|
self.relationship_ref().relationship.as_ref()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait RelationshipMutExt: RelationshipMut {
|
|
|
|
fn set_subject<T>(&mut self, subject: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
self.relationship_mut().subject = Some(subject.into());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_subject(&mut self) -> Option<AnyObject> {
|
|
|
|
self.relationship_mut().subject.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_subject(&mut self) -> &mut Self {
|
|
|
|
self.relationship_mut().subject = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_object<T>(&mut self, object: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
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>,
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
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
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_object(&mut self) -> Option<OneOrMany<AnyObject>> {
|
|
|
|
self.relationship_mut().object.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_object(&mut self) -> &mut Self {
|
|
|
|
self.relationship_mut().object = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_relationship<T>(&mut self, relationship: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
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>,
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
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
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_relationship(&mut self) -> Option<OneOrMany<AnyObject>> {
|
|
|
|
self.relationship_mut().relationship.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_relationship(&mut self) -> &mut Self {
|
|
|
|
self.relationship_mut().relationship = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait TombstoneRefExt: TombstoneRef {
|
|
|
|
fn former_type(&self) -> Option<&OneOrMany<AnyObject>> {
|
|
|
|
self.tombstone_ref().former_type.as_ref()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn deleted(&self) -> Option<&XsdDateTime> {
|
|
|
|
self.tombstone_ref().deleted.as_ref()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait TombstoneMutExt: TombstoneMut {
|
|
|
|
fn set_former_type<T>(&mut self, former_type: T) -> &mut Self
|
|
|
|
where
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
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>,
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
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
|
|
|
|
T: Into<AnyObject>,
|
|
|
|
{
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_former_type(&mut self) -> Option<OneOrMany<AnyObject>> {
|
|
|
|
self.tombstone_mut().former_type.take()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn delete_former_type(&mut self) -> &mut Self {
|
|
|
|
self.tombstone_mut().former_type = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
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>;
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
|
|
|
|
#[serde(transparent)]
|
|
|
|
struct IdOrObject(Either<XsdAnyUri, Box<Object<serde_json::Value>>>);
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
|
|
|
|
#[serde(transparent)]
|
|
|
|
pub struct AnyObject(Either<IdOrObject, XsdString>);
|
|
|
|
|
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> {
|
|
|
|
#[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 context: Option<OneOrMany<AnyObject>>,
|
|
|
|
|
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default, setter(strip_option, into))]
|
2020-05-15 03:18:34 +00:00
|
|
|
pub id: Option<XsdAnyUri>,
|
2020-05-14 03:54:50 +00:00
|
|
|
|
|
|
|
#[serde(rename = "type")]
|
|
|
|
#[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 kind: Option<Kind>,
|
|
|
|
|
|
|
|
#[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 attachment: Option<OneOrMany<AnyObject>>,
|
|
|
|
|
|
|
|
#[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 attributed_to: Option<OneOrMany<AnyObject>>,
|
|
|
|
|
|
|
|
#[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 audience: Option<OneOrMany<AnyObject>>,
|
|
|
|
|
|
|
|
#[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>>,
|
|
|
|
|
|
|
|
#[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 name: Option<OneOrMany<AnyString>>,
|
|
|
|
|
|
|
|
#[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>>,
|
|
|
|
|
|
|
|
#[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 url: Option<OneOrMany<AnyObject>>,
|
|
|
|
|
|
|
|
#[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 media_type: Option<MimeMediaType>,
|
|
|
|
|
|
|
|
#[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 generator: Option<OneOrMany<AnyObject>>,
|
|
|
|
|
|
|
|
#[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 image: Option<OneOrMany<AnyObject>>,
|
|
|
|
|
|
|
|
#[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 location: Option<OneOrMany<AnyObject>>,
|
|
|
|
|
|
|
|
#[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 preview: Option<OneOrMany<AnyObject>>,
|
|
|
|
|
|
|
|
#[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>,
|
|
|
|
|
|
|
|
#[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>,
|
|
|
|
|
|
|
|
#[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>,
|
|
|
|
|
|
|
|
#[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>,
|
|
|
|
|
|
|
|
#[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>,
|
|
|
|
|
|
|
|
#[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 in_reply_to: Option<OneOrMany<AnyObject>>,
|
|
|
|
|
|
|
|
#[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 replies: Option<OneOrMany<AnyObject>>,
|
|
|
|
|
|
|
|
#[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 to: Option<OneOrMany<AnyObject>>,
|
|
|
|
|
|
|
|
#[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 bto: Option<OneOrMany<AnyObject>>,
|
|
|
|
|
|
|
|
#[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 cc: Option<OneOrMany<AnyObject>>,
|
|
|
|
|
|
|
|
#[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 bcc: Option<OneOrMany<AnyObject>>,
|
|
|
|
|
|
|
|
#[serde(flatten)]
|
2020-05-14 16:23:38 +00:00
|
|
|
#[builder(default)]
|
2020-05-14 03:54:50 +00:00
|
|
|
pub unparsed: Unparsed,
|
|
|
|
}
|
|
|
|
|
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> {
|
|
|
|
#[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>,
|
|
|
|
|
|
|
|
#[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>,
|
|
|
|
|
|
|
|
#[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 source: Option<AnyObject>,
|
|
|
|
|
|
|
|
#[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>>,
|
|
|
|
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub inner: Inner,
|
|
|
|
}
|
|
|
|
|
2020-05-14 16:23:38 +00:00
|
|
|
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize, TypedBuilder)]
|
|
|
|
#[builder(doc)]
|
2020-05-14 03:54:50 +00:00
|
|
|
pub struct Place {
|
|
|
|
#[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
|
|
|
|
|
|
|
#[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
|
|
|
|
|
|
|
#[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
|
|
|
|
|
|
|
#[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
|
|
|
|
|
|
|
#[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
|
|
|
|
|
|
|
#[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>,
|
|
|
|
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub inner: Object<PlaceType>,
|
|
|
|
}
|
|
|
|
|
2020-05-14 16:23:38 +00:00
|
|
|
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize, TypedBuilder)]
|
|
|
|
#[builder(doc)]
|
2020-05-14 03:54:50 +00:00
|
|
|
pub struct Profile {
|
|
|
|
#[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 describes: Option<AnyObject>,
|
|
|
|
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub inner: Object<ProfileType>,
|
|
|
|
}
|
|
|
|
|
2020-05-14 16:23:38 +00:00
|
|
|
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize, TypedBuilder)]
|
|
|
|
#[builder(doc)]
|
2020-05-14 03:54:50 +00:00
|
|
|
pub struct Relationship {
|
|
|
|
#[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 subject: Option<AnyObject>,
|
|
|
|
|
|
|
|
#[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 object: Option<OneOrMany<AnyObject>>,
|
|
|
|
|
|
|
|
#[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 relationship: Option<OneOrMany<AnyObject>>,
|
|
|
|
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub inner: Object<RelationshipType>,
|
|
|
|
}
|
|
|
|
|
2020-05-14 16:23:38 +00:00
|
|
|
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize, TypedBuilder)]
|
|
|
|
#[builder(doc)]
|
2020-05-14 03:54:50 +00:00
|
|
|
pub struct Tombstone {
|
|
|
|
#[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 former_type: Option<OneOrMany<AnyObject>>,
|
|
|
|
|
|
|
|
#[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>,
|
|
|
|
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub inner: Object<TombstoneType>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl AnyObject {
|
|
|
|
pub fn as_xsd_any_uri(&self) -> Option<&XsdAnyUri> {
|
|
|
|
self.0.as_ref().left().and_then(|l| l.as_xsd_any_uri())
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn as_xsd_string(&self) -> Option<&XsdString> {
|
|
|
|
self.0.as_ref().right()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn as_object(&self) -> Option<&Object<serde_json::Value>> {
|
|
|
|
self.0.as_ref().left().and_then(|l| l.as_object())
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn id(self) -> Option<XsdAnyUri> {
|
|
|
|
self.0.left().and_then(|l| l.id())
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn xsd_string(self) -> Option<XsdString> {
|
|
|
|
self.0.right()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn object(self) -> Option<Object<serde_json::Value>> {
|
|
|
|
self.0.left().and_then(|l| l.object())
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn set_xsd_any_uri(&mut self, id: XsdAnyUri) {
|
|
|
|
self.0 = Either::Left(IdOrObject::from_xsd_any_uri(id));
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn set_object(&mut self, object: Object<serde_json::Value>) {
|
|
|
|
self.0 = Either::Left(IdOrObject::from_object(object));
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn set_xsd_string(&mut self, xsd_string: XsdString) {
|
|
|
|
self.0 = Either::Right(xsd_string);
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn from_xsd_any_uri(id: XsdAnyUri) -> Self {
|
|
|
|
AnyObject(Either::Left(IdOrObject::from_xsd_any_uri(id)))
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn from_object(object: Object<serde_json::Value>) -> Self {
|
|
|
|
AnyObject(Either::Left(IdOrObject::from_object(object)))
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn from_xsd_string(xsd_string: XsdString) -> Self {
|
|
|
|
AnyObject(Either::Right(xsd_string))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl IdOrObject {
|
|
|
|
fn as_xsd_any_uri(&self) -> Option<&XsdAnyUri> {
|
|
|
|
self.0.as_ref().left()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn as_object(&self) -> Option<&Object<serde_json::Value>> {
|
|
|
|
self.0.as_ref().right().map(|b| b.as_ref())
|
|
|
|
}
|
|
|
|
|
|
|
|
fn id(self) -> Option<XsdAnyUri> {
|
|
|
|
self.0.left()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn object(self) -> Option<Object<serde_json::Value>> {
|
|
|
|
self.0.right().map(|b| *b)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn from_xsd_any_uri(id: XsdAnyUri) -> Self {
|
|
|
|
IdOrObject(Either::Left(id))
|
|
|
|
}
|
|
|
|
|
|
|
|
fn from_object(object: Object<serde_json::Value>) -> Self {
|
|
|
|
IdOrObject(Either::Right(Box::new(object)))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl OneOrMany<AnyObject> {
|
|
|
|
pub fn as_single_xsd_any_uri(&self) -> Option<&XsdAnyUri> {
|
|
|
|
self.as_one().and_then(|inner| inner.as_xsd_any_uri())
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn as_single_xsd_string(&self) -> Option<&XsdString> {
|
|
|
|
self.as_one().and_then(|inner| inner.as_xsd_string())
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn as_single_object(&self) -> Option<&Object<serde_json::Value>> {
|
|
|
|
self.as_one().and_then(|inner| inner.as_object())
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn single_xsd_any_uri(self) -> Option<XsdAnyUri> {
|
|
|
|
self.one().and_then(|inner| inner.id())
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn single_xsd_string(self) -> Option<XsdString> {
|
|
|
|
self.one().and_then(|inner| inner.xsd_string())
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn single_object(self) -> Option<Object<serde_json::Value>> {
|
|
|
|
self.one().and_then(|inner| inner.object())
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn from_xsd_any_uri(id: XsdAnyUri) -> Self {
|
|
|
|
OneOrMany(Either::Left(AnyObject::from_xsd_any_uri(id)))
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn from_xsd_string(xsd_string: XsdString) -> Self {
|
|
|
|
OneOrMany(Either::Left(AnyObject::from_xsd_string(xsd_string)))
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn from_object(object: Object<serde_json::Value>) -> Self {
|
|
|
|
OneOrMany(Either::Left(AnyObject::from_object(object)))
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn set_single_xsd_any_uri(&mut self, id: XsdAnyUri) -> &mut Self {
|
|
|
|
self.0 = Either::Left(AnyObject::from_xsd_any_uri(id));
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn set_single_xsd_string(&mut self, xsd_string: XsdString) -> &mut Self {
|
|
|
|
self.0 = Either::Left(AnyObject::from_xsd_string(xsd_string));
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn set_single_object(&mut self, object: Object<serde_json::Value>) -> &mut Self {
|
|
|
|
self.0 = Either::Left(AnyObject::from_object(object));
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn add_xsd_any_uri(&mut self, id: XsdAnyUri) -> &mut Self {
|
|
|
|
self.add(AnyObject::from_xsd_any_uri(id))
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn add_xsd_string(&mut self, xsd_string: XsdString) -> &mut Self {
|
|
|
|
self.add(AnyObject::from_xsd_string(xsd_string))
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn add_object(&mut self, object: Object<serde_json::Value>) -> &mut Self {
|
|
|
|
self.add(AnyObject::from_object(object))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Object<serde_json::Value> {
|
|
|
|
pub fn solidify<Kind>(self) -> Result<Object<Kind>, serde_json::Error>
|
|
|
|
where
|
|
|
|
Kind: serde::de::DeserializeOwned,
|
|
|
|
{
|
|
|
|
self.try_map_kind(serde_json::from_value)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<Kind> Object<Kind> {
|
2020-05-14 16:23:38 +00:00
|
|
|
fn extending(mut unparsed: Unparsed) -> Result<Self, serde_json::Error>
|
|
|
|
where
|
|
|
|
Kind: serde::de::DeserializeOwned,
|
|
|
|
{
|
|
|
|
Ok(Object {
|
2020-05-15 03:18:34 +00:00
|
|
|
kind: UnparsedMutExt::remove(&mut unparsed, "type")?,
|
|
|
|
context: UnparsedMutExt::remove(&mut unparsed, "context")?,
|
|
|
|
id: UnparsedMutExt::remove(&mut unparsed, "id")?,
|
|
|
|
attachment: UnparsedMutExt::remove(&mut unparsed, "attachment")?,
|
|
|
|
attributed_to: UnparsedMutExt::remove(&mut unparsed, "attributedTo")?,
|
|
|
|
audience: UnparsedMutExt::remove(&mut unparsed, "audience")?,
|
|
|
|
content: UnparsedMutExt::remove(&mut unparsed, "content")?,
|
|
|
|
name: UnparsedMutExt::remove(&mut unparsed, "name")?,
|
|
|
|
summary: UnparsedMutExt::remove(&mut unparsed, "summary")?,
|
|
|
|
url: UnparsedMutExt::remove(&mut unparsed, "url")?,
|
|
|
|
media_type: UnparsedMutExt::remove(&mut unparsed, "mediaType")?,
|
|
|
|
generator: UnparsedMutExt::remove(&mut unparsed, "generator")?,
|
|
|
|
image: UnparsedMutExt::remove(&mut unparsed, "image")?,
|
|
|
|
location: UnparsedMutExt::remove(&mut unparsed, "location")?,
|
|
|
|
preview: UnparsedMutExt::remove(&mut unparsed, "preview")?,
|
|
|
|
start_time: UnparsedMutExt::remove(&mut unparsed, "startTime")?,
|
|
|
|
end_time: UnparsedMutExt::remove(&mut unparsed, "endTime")?,
|
|
|
|
duration: UnparsedMutExt::remove(&mut unparsed, "duration")?,
|
|
|
|
published: UnparsedMutExt::remove(&mut unparsed, "published")?,
|
|
|
|
updated: UnparsedMutExt::remove(&mut unparsed, "updated")?,
|
|
|
|
in_reply_to: UnparsedMutExt::remove(&mut unparsed, "inReplyTo")?,
|
|
|
|
replies: UnparsedMutExt::remove(&mut unparsed, "replies")?,
|
|
|
|
to: UnparsedMutExt::remove(&mut unparsed, "to")?,
|
|
|
|
bto: UnparsedMutExt::remove(&mut unparsed, "bto")?,
|
|
|
|
cc: UnparsedMutExt::remove(&mut unparsed, "cc")?,
|
|
|
|
bcc: UnparsedMutExt::remove(&mut unparsed, "bcc")?,
|
2020-05-14 16:23:38 +00:00
|
|
|
unparsed,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
fn retracting(self) -> Result<Unparsed, serde_json::Error>
|
|
|
|
where
|
|
|
|
Kind: serde::ser::Serialize,
|
|
|
|
{
|
|
|
|
let Object {
|
|
|
|
kind,
|
|
|
|
context,
|
|
|
|
id,
|
|
|
|
attachment,
|
|
|
|
attributed_to,
|
|
|
|
audience,
|
|
|
|
content,
|
|
|
|
name,
|
|
|
|
summary,
|
|
|
|
url,
|
|
|
|
media_type,
|
|
|
|
generator,
|
|
|
|
image,
|
|
|
|
location,
|
|
|
|
preview,
|
|
|
|
start_time,
|
|
|
|
end_time,
|
|
|
|
duration,
|
|
|
|
published,
|
|
|
|
updated,
|
|
|
|
in_reply_to,
|
|
|
|
replies,
|
|
|
|
to,
|
|
|
|
bto,
|
|
|
|
cc,
|
|
|
|
bcc,
|
|
|
|
mut unparsed,
|
|
|
|
} = self;
|
|
|
|
|
2020-05-15 03:18:34 +00:00
|
|
|
UnparsedMutExt::insert(&mut unparsed, "type", kind)?;
|
|
|
|
UnparsedMutExt::insert(&mut unparsed, "context", context)?;
|
|
|
|
UnparsedMutExt::insert(&mut unparsed, "id", id)?;
|
|
|
|
UnparsedMutExt::insert(&mut unparsed, "attachment", attachment)?;
|
|
|
|
UnparsedMutExt::insert(&mut unparsed, "attributedTo", attributed_to)?;
|
|
|
|
UnparsedMutExt::insert(&mut unparsed, "audience", audience)?;
|
|
|
|
UnparsedMutExt::insert(&mut unparsed, "content", content)?;
|
|
|
|
UnparsedMutExt::insert(&mut unparsed, "name", name)?;
|
|
|
|
UnparsedMutExt::insert(&mut unparsed, "summary", summary)?;
|
|
|
|
UnparsedMutExt::insert(&mut unparsed, "url", url)?;
|
|
|
|
UnparsedMutExt::insert(&mut unparsed, "mediaType", media_type)?;
|
|
|
|
UnparsedMutExt::insert(&mut unparsed, "generator", generator)?;
|
|
|
|
UnparsedMutExt::insert(&mut unparsed, "image", image)?;
|
|
|
|
UnparsedMutExt::insert(&mut unparsed, "location", location)?;
|
|
|
|
UnparsedMutExt::insert(&mut unparsed, "preview", preview)?;
|
|
|
|
UnparsedMutExt::insert(&mut unparsed, "startTime", start_time)?;
|
|
|
|
UnparsedMutExt::insert(&mut unparsed, "endTime", end_time)?;
|
|
|
|
UnparsedMutExt::insert(&mut unparsed, "duration", duration)?;
|
|
|
|
UnparsedMutExt::insert(&mut unparsed, "published", published)?;
|
|
|
|
UnparsedMutExt::insert(&mut unparsed, "updated", updated)?;
|
|
|
|
UnparsedMutExt::insert(&mut unparsed, "inReplyTo", in_reply_to)?;
|
|
|
|
UnparsedMutExt::insert(&mut unparsed, "replies", replies)?;
|
|
|
|
UnparsedMutExt::insert(&mut unparsed, "to", to)?;
|
|
|
|
UnparsedMutExt::insert(&mut unparsed, "bto", bto)?;
|
|
|
|
UnparsedMutExt::insert(&mut unparsed, "cc", cc)?;
|
|
|
|
UnparsedMutExt::insert(&mut unparsed, "bcc", bcc)?;
|
2020-05-14 16:23:38 +00:00
|
|
|
|
|
|
|
Ok(unparsed)
|
|
|
|
}
|
|
|
|
|
2020-05-14 03:54:50 +00:00
|
|
|
pub fn into_generic(self) -> Result<Object<serde_json::Value>, serde_json::Error>
|
|
|
|
where
|
|
|
|
Kind: serde::ser::Serialize,
|
|
|
|
{
|
|
|
|
self.try_map_kind(serde_json::to_value)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn map_kind<NewKind>(self, f: impl Fn(Kind) -> NewKind) -> Object<NewKind> {
|
|
|
|
Object {
|
|
|
|
kind: self.kind.map(f),
|
|
|
|
context: self.context,
|
|
|
|
id: self.id,
|
|
|
|
attachment: self.attachment,
|
|
|
|
attributed_to: self.attributed_to,
|
|
|
|
audience: self.audience,
|
|
|
|
content: self.content,
|
|
|
|
name: self.name,
|
|
|
|
summary: self.summary,
|
|
|
|
url: self.url,
|
|
|
|
media_type: self.media_type,
|
|
|
|
generator: self.generator,
|
|
|
|
image: self.image,
|
|
|
|
location: self.location,
|
|
|
|
preview: self.preview,
|
|
|
|
start_time: self.start_time,
|
|
|
|
end_time: self.end_time,
|
|
|
|
duration: self.duration,
|
|
|
|
published: self.published,
|
|
|
|
updated: self.updated,
|
|
|
|
in_reply_to: self.in_reply_to,
|
|
|
|
replies: self.replies,
|
|
|
|
to: self.to,
|
|
|
|
bto: self.bto,
|
|
|
|
cc: self.cc,
|
|
|
|
bcc: self.bcc,
|
|
|
|
unparsed: self.unparsed,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn try_map_kind<NewKind, E>(
|
|
|
|
self,
|
|
|
|
f: impl Fn(Kind) -> Result<NewKind, E>,
|
|
|
|
) -> Result<Object<NewKind>, E> {
|
|
|
|
Ok(Object {
|
|
|
|
kind: if let Some(kind) = self.kind {
|
|
|
|
Some((f)(kind)?)
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
},
|
|
|
|
context: self.context,
|
|
|
|
id: self.id,
|
|
|
|
attachment: self.attachment,
|
|
|
|
attributed_to: self.attributed_to,
|
|
|
|
audience: self.audience,
|
|
|
|
content: self.content,
|
|
|
|
name: self.name,
|
|
|
|
summary: self.summary,
|
|
|
|
url: self.url,
|
|
|
|
media_type: self.media_type,
|
|
|
|
generator: self.generator,
|
|
|
|
image: self.image,
|
|
|
|
location: self.location,
|
|
|
|
preview: self.preview,
|
|
|
|
start_time: self.start_time,
|
|
|
|
end_time: self.end_time,
|
|
|
|
duration: self.duration,
|
|
|
|
published: self.published,
|
|
|
|
updated: self.updated,
|
|
|
|
in_reply_to: self.in_reply_to,
|
|
|
|
replies: self.replies,
|
|
|
|
to: self.to,
|
|
|
|
bto: self.bto,
|
|
|
|
cc: self.cc,
|
|
|
|
bcc: self.bcc,
|
|
|
|
unparsed: self.unparsed,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn extend<Extended>(self) -> Result<Extended, Extended::Error>
|
|
|
|
where
|
|
|
|
Extended: Extends<Self>,
|
|
|
|
{
|
|
|
|
Extended::extends(self)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<Inner> ApObject<Inner> {
|
|
|
|
fn extending(mut inner: Inner) -> Result<Self, serde_json::Error>
|
|
|
|
where
|
2020-05-15 03:18:34 +00:00
|
|
|
Inner: UnparsedMut + traits::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 03:18:34 +00:00
|
|
|
Inner: UnparsedMut + traits::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-14 16:23:38 +00:00
|
|
|
impl<Kind> Extends<Unparsed> for Object<Kind>
|
|
|
|
where
|
|
|
|
Kind: serde::de::DeserializeOwned + serde::ser::Serialize,
|
|
|
|
{
|
|
|
|
type Error = serde_json::Error;
|
|
|
|
|
|
|
|
fn extends(unparsed: Unparsed) -> Result<Self, Self::Error> {
|
|
|
|
Self::extending(unparsed)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn retracts(self) -> Result<Unparsed, Self::Error> {
|
|
|
|
self.retracting()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<Kind> TryFrom<Unparsed> for Object<Kind>
|
|
|
|
where
|
|
|
|
Kind: serde::de::DeserializeOwned,
|
|
|
|
{
|
|
|
|
type Error = serde_json::Error;
|
|
|
|
|
|
|
|
fn try_from(unparsed: Unparsed) -> Result<Self, Self::Error> {
|
|
|
|
Self::extending(unparsed)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<Kind> TryFrom<Object<Kind>> for Unparsed
|
|
|
|
where
|
|
|
|
Kind: serde::ser::Serialize,
|
|
|
|
{
|
|
|
|
type Error = serde_json::Error;
|
|
|
|
|
|
|
|
fn try_from(object: Object<Kind>) -> Result<Self, Self::Error> {
|
|
|
|
object.retracting()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-14 03:54:50 +00:00
|
|
|
impl<Inner> Extends<Inner> for ApObject<Inner>
|
|
|
|
where
|
2020-05-15 03:18:34 +00:00
|
|
|
Inner: UnparsedMut + traits::Object,
|
2020-05-14 03:54:50 +00:00
|
|
|
{
|
|
|
|
type Error = serde_json::Error;
|
|
|
|
|
|
|
|
fn extends(inner: Inner) -> Result<Self, Self::Error> {
|
|
|
|
Self::extending(inner)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn retracts(self) -> Result<Inner, Self::Error> {
|
|
|
|
self.retracting()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Extends<Object<PlaceType>> for Place {
|
|
|
|
type Error = serde_json::Error;
|
|
|
|
|
|
|
|
fn extends(object: Object<PlaceType>) -> Result<Self, Self::Error> {
|
|
|
|
Self::extending(object)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn retracts(self) -> Result<Object<PlaceType>, Self::Error> {
|
|
|
|
self.retracting()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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-14 03:54:50 +00:00
|
|
|
impl Extends<Object<ProfileType>> for Profile {
|
|
|
|
type Error = serde_json::Error;
|
|
|
|
|
|
|
|
fn extends(object: Object<ProfileType>) -> Result<Self, Self::Error> {
|
|
|
|
Self::extending(object)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn retracts(self) -> Result<Object<ProfileType>, Self::Error> {
|
|
|
|
self.retracting()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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-14 03:54:50 +00:00
|
|
|
impl Extends<Object<RelationshipType>> for Relationship {
|
|
|
|
type Error = serde_json::Error;
|
|
|
|
|
|
|
|
fn extends(object: Object<RelationshipType>) -> Result<Self, Self::Error> {
|
|
|
|
Self::extending(object)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn retracts(self) -> Result<Object<RelationshipType>, Self::Error> {
|
|
|
|
self.retracting()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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-14 03:54:50 +00:00
|
|
|
impl Extends<Object<TombstoneType>> for Tombstone {
|
|
|
|
type Error = serde_json::Error;
|
|
|
|
|
|
|
|
fn extends(object: Object<TombstoneType>) -> Result<Self, Self::Error> {
|
|
|
|
Self::extending(object)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn retracts(self) -> Result<Object<TombstoneType>, Self::Error> {
|
|
|
|
self.retracting()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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 {
|
|
|
|
&mut self.unparsed
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<Object<serde_json::Value>> for AnyObject {
|
|
|
|
fn from(o: Object<serde_json::Value>) -> Self {
|
|
|
|
Self::from_object(o)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<XsdAnyUri> for AnyObject {
|
|
|
|
fn from(id: XsdAnyUri) -> Self {
|
|
|
|
Self::from_xsd_any_uri(id)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<XsdString> for AnyObject {
|
|
|
|
fn from(xsd_string: XsdString) -> Self {
|
|
|
|
Self::from_xsd_string(xsd_string)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<Object<serde_json::Value>> for OneOrMany<AnyObject> {
|
|
|
|
fn from(object: Object<serde_json::Value>) -> Self {
|
|
|
|
Self::from_object(object)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<XsdAnyUri> for OneOrMany<AnyObject> {
|
|
|
|
fn from(xsd_any_uri: XsdAnyUri) -> Self {
|
|
|
|
Self::from_xsd_any_uri(xsd_any_uri)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<XsdString> for OneOrMany<AnyObject> {
|
|
|
|
fn from(xsd_string: XsdString) -> Self {
|
|
|
|
Self::from_xsd_string(xsd_string)
|
|
|
|
}
|
|
|
|
}
|
2020-05-15 03:18:34 +00:00
|
|
|
|
|
|
|
impl<Kind> traits::Base for Object<Kind> {}
|
|
|
|
impl<Kind> traits::Object for Object<Kind> {}
|
|
|
|
|
|
|
|
impl<Inner> traits::Base for ApObject<Inner> where Inner: traits::Base {}
|
|
|
|
impl<Inner> traits::Object for ApObject<Inner> where Inner: traits::Object {}
|
|
|
|
|
|
|
|
impl traits::Base for Place {}
|
|
|
|
impl traits::Object for Place {}
|
|
|
|
|
|
|
|
impl traits::Base for Profile {}
|
|
|
|
impl traits::Object for Profile {}
|
|
|
|
|
|
|
|
impl traits::Base for Relationship {}
|
|
|
|
impl traits::Object for Relationship {}
|
|
|
|
|
|
|
|
impl traits::Base for Tombstone {}
|
|
|
|
impl traits::Object for Tombstone {}
|
|
|
|
|
|
|
|
impl<T, Kind> ObjectRefExt<Kind> for T where T: ObjectRef<Kind> {}
|
|
|
|
impl<T, Kind> ObjectMutExt<Kind> for T where T: ObjectMut<Kind> {}
|
|
|
|
|
|
|
|
impl<T, Inner> ApObjectRefExt<Inner> for T where T: ApObjectRef<Inner> {}
|
|
|
|
impl<T, Inner> ApObjectMutExt<Inner> for T where T: ApObjectMut<Inner> {}
|
|
|
|
|
|
|
|
impl<T> PlaceRefExt for T where T: PlaceRef {}
|
|
|
|
impl<T> PlaceMutExt for T where T: PlaceMut {}
|
|
|
|
|
|
|
|
impl<T> ProfileRefExt for T where T: ProfileRef {}
|
|
|
|
impl<T> ProfileMutExt for T where T: ProfileMut {}
|
|
|
|
|
|
|
|
impl<T> RelationshipRefExt for T where T: RelationshipRef {}
|
|
|
|
impl<T> RelationshipMutExt for T where T: RelationshipMut {}
|
|
|
|
|
|
|
|
impl<T> TombstoneRefExt for T where T: TombstoneRef {}
|
|
|
|
impl<T> TombstoneMutExt for T where T: TombstoneMut {}
|
|
|
|
|
|
|
|
impl<Kind> ObjectRef<Kind> for Object<Kind> {
|
|
|
|
fn object_ref(&self) -> &Object<Kind> {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl<Kind> ObjectMut<Kind> for Object<Kind> {
|
|
|
|
fn object_mut(&mut self) -> &mut Object<Kind> {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<Inner, Kind> ObjectRef<Kind> for ApObject<Inner>
|
|
|
|
where
|
|
|
|
Inner: ObjectRef<Kind>,
|
|
|
|
{
|
|
|
|
fn object_ref(&self) -> &Object<Kind> {
|
|
|
|
self.inner.object_ref()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl<Inner, Kind> ObjectMut<Kind> for ApObject<Inner>
|
|
|
|
where
|
|
|
|
Inner: ObjectMut<Kind>,
|
|
|
|
{
|
|
|
|
fn object_mut(&mut self) -> &mut Object<Kind> {
|
|
|
|
self.inner.object_mut()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<Inner> ApObjectRef<Inner> for ApObject<Inner>
|
|
|
|
where
|
|
|
|
Inner: traits::Object,
|
|
|
|
{
|
|
|
|
fn ap_object_ref(&self) -> &ApObject<Inner> {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl<Inner> ApObjectMut<Inner> for ApObject<Inner>
|
|
|
|
where
|
|
|
|
Inner: traits::Object,
|
|
|
|
{
|
|
|
|
fn ap_object_mut(&mut self) -> &mut ApObject<Inner> {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<Inner> PlaceRef for ApObject<Inner>
|
|
|
|
where
|
|
|
|
Inner: PlaceRef,
|
|
|
|
{
|
|
|
|
fn place_ref(&self) -> &Place {
|
|
|
|
self.inner.place_ref()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl<Inner> PlaceMut for ApObject<Inner>
|
|
|
|
where
|
|
|
|
Inner: PlaceMut,
|
|
|
|
{
|
|
|
|
fn place_mut(&mut self) -> &mut Place {
|
|
|
|
self.inner.place_mut()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<Inner> ProfileRef for ApObject<Inner>
|
|
|
|
where
|
|
|
|
Inner: ProfileRef,
|
|
|
|
{
|
|
|
|
fn profile_ref(&self) -> &Profile {
|
|
|
|
self.inner.profile_ref()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl<Inner> ProfileMut for ApObject<Inner>
|
|
|
|
where
|
|
|
|
Inner: ProfileMut,
|
|
|
|
{
|
|
|
|
fn profile_mut(&mut self) -> &mut Profile {
|
|
|
|
self.inner.profile_mut()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<Inner> RelationshipRef for ApObject<Inner>
|
|
|
|
where
|
|
|
|
Inner: RelationshipRef,
|
|
|
|
{
|
|
|
|
fn relationship_ref(&self) -> &Relationship {
|
|
|
|
self.inner.relationship_ref()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl<Inner> RelationshipMut for ApObject<Inner>
|
|
|
|
where
|
|
|
|
Inner: RelationshipMut,
|
|
|
|
{
|
|
|
|
fn relationship_mut(&mut self) -> &mut Relationship {
|
|
|
|
self.inner.relationship_mut()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<Inner> TombstoneRef for ApObject<Inner>
|
|
|
|
where
|
|
|
|
Inner: TombstoneRef,
|
|
|
|
{
|
|
|
|
fn tombstone_ref(&self) -> &Tombstone {
|
|
|
|
self.inner.tombstone_ref()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl<Inner> TombstoneMut for ApObject<Inner>
|
|
|
|
where
|
|
|
|
Inner: TombstoneMut,
|
|
|
|
{
|
|
|
|
fn tombstone_mut(&mut self) -> &mut Tombstone {
|
|
|
|
self.inner.tombstone_mut()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl PlaceRef for Place {
|
|
|
|
fn place_ref(&self) -> &Place {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl PlaceMut for Place {
|
|
|
|
fn place_mut(&mut self) -> &mut Place {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl ProfileRef for Profile {
|
|
|
|
fn profile_ref(&self) -> &Profile {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl ProfileMut for Profile {
|
|
|
|
fn profile_mut(&mut self) -> &mut Profile {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl RelationshipRef for Relationship {
|
|
|
|
fn relationship_ref(&self) -> &Relationship {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl RelationshipMut for Relationship {
|
|
|
|
fn relationship_mut(&mut self) -> &mut Relationship {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl TombstoneRef for Tombstone {
|
|
|
|
fn tombstone_ref(&self) -> &Tombstone {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl TombstoneMut for Tombstone {
|
|
|
|
fn tombstone_mut(&mut self) -> &mut Tombstone {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|