use crate::{ either::Either, primitives::{ AnyString, MimeMediaType, OneOrMany, Unit, Unparsed, XsdAnyUri, XsdDateTime, XsdDuration, XsdFloat, XsdString, }, traits::{self, Extends, UnparsedMut, UnparsedMutExt}, }; use std::convert::TryFrom; use typed_builder::TypedBuilder; pub mod kind { pub use activitystreams::object::kind::*; } use self::kind::*; pub trait ObjectRef: traits::Object { fn object_ref(&self) -> &Object; } pub trait ObjectMut: traits::Object { fn object_mut(&mut self) -> &mut Object; } pub trait ApObjectRef: traits::Object { fn ap_object_ref(&self) -> &ApObject; } pub trait ApObjectMut: traits::Object { fn ap_object_mut(&mut self) -> &mut ApObject; } 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: ObjectRef { fn context<'a>(&'a self) -> Option<&'a OneOrMany> 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> where Kind: 'a, { self.object_ref().attachment.as_ref() } fn attributed_to<'a>(&'a self) -> Option<&'a OneOrMany> where Kind: 'a, { self.object_ref().attributed_to.as_ref() } fn audience<'a>(&'a self) -> Option<&'a OneOrMany> where Kind: 'a, { self.object_ref().audience.as_ref() } fn content<'a>(&'a self) -> Option<&'a OneOrMany> where Kind: 'a, { self.object_ref().content.as_ref() } fn name<'a>(&'a self) -> Option<&'a OneOrMany> where Kind: 'a, { self.object_ref().name.as_ref() } fn summary<'a>(&'a self) -> Option<&'a OneOrMany> where Kind: 'a, { self.object_ref().summary.as_ref() } fn url<'a>(&'a self) -> Option<&'a OneOrMany> 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> where Kind: 'a, { self.object_ref().generator.as_ref() } fn image<'a>(&'a self) -> Option<&'a OneOrMany> where Kind: 'a, { self.object_ref().image.as_ref() } fn location<'a>(&'a self) -> Option<&'a OneOrMany> where Kind: 'a, { self.object_ref().location.as_ref() } fn preview<'a>(&'a self) -> Option<&'a OneOrMany> 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> where Kind: 'a, { self.object_ref().in_reply_to.as_ref() } fn replies<'a>(&'a self) -> Option<&'a OneOrMany> where Kind: 'a, { self.object_ref().replies.as_ref() } fn to<'a>(&'a self) -> Option<&'a OneOrMany> where Kind: 'a, { self.object_ref().to.as_ref() } fn bto<'a>(&'a self) -> Option<&'a OneOrMany> where Kind: 'a, { self.object_ref().bto.as_ref() } fn cc<'a>(&'a self) -> Option<&'a OneOrMany> where Kind: 'a, { self.object_ref().cc.as_ref() } fn bcc<'a>(&'a self) -> Option<&'a OneOrMany> where Kind: 'a, { self.object_ref().bcc.as_ref() } } pub trait ObjectMutExt: ObjectMut { fn set_context(&mut self, context: T) -> &mut Self where T: Into, { self.object_mut().context = Some(context.into().into()); self } fn set_many_contexts(&mut self, items: I) -> &mut Self where I: IntoIterator, T: Into, { let v: Vec<_> = items.into_iter().map(Into::into).collect(); self.object_mut().context = Some(v.into()); self } fn add_context(&mut self, context: T) -> &mut Self where T: Into, { 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> { 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 { 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 { self.object_mut().kind.take() } fn delete_kind(&mut self) -> &mut Self { self.object_mut().kind = None; self } fn set_attachment(&mut self, attachment: T) -> &mut Self where T: Into, { self.object_mut().attachment = Some(attachment.into().into()); self } fn set_many_attachments(&mut self, items: I) -> &mut Self where I: IntoIterator, T: Into, { let v: Vec<_> = items.into_iter().map(Into::into).collect(); self.object_mut().attachment = Some(v.into()); self } fn add_attachment(&mut self, attachment: T) -> &mut Self where T: Into, { 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> { self.object_mut().attachment.take() } fn delete_attachment(&mut self) -> &mut Self { self.object_mut().attachment = None; self } fn set_attributed_to(&mut self, attributed_to: T) -> &mut Self where T: Into, { self.object_mut().attributed_to = Some(attributed_to.into().into()); self } fn set_many_attributed_tos(&mut self, items: I) -> &mut Self where I: IntoIterator, T: Into, { let v: Vec<_> = items.into_iter().map(Into::into).collect(); self.object_mut().attributed_to = Some(v.into()); self } fn add_attributed_to(&mut self, attributed_to: T) -> &mut Self where T: Into, { 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> { self.object_mut().attributed_to.take() } fn delete_attributed_to(&mut self) -> &mut Self { self.object_mut().attributed_to = None; self } fn set_audience(&mut self, audience: T) -> &mut Self where T: Into, { self.object_mut().audience = Some(audience.into().into()); self } fn set_many_audiences(&mut self, items: I) -> &mut Self where I: IntoIterator, T: Into, { let v: Vec<_> = items.into_iter().map(Into::into).collect(); self.object_mut().audience = Some(v.into()); self } fn add_audience(&mut self, audience: T) -> &mut Self where T: Into, { 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> { self.object_mut().audience.take() } fn delete_audience(&mut self) -> &mut Self { self.object_mut().audience = None; self } fn set_content(&mut self, content: T) -> &mut Self where T: Into, { self.object_mut().content = Some(content.into().into()); self } fn set_many_contents(&mut self, items: I) -> &mut Self where I: IntoIterator, T: Into, { let v: Vec<_> = items.into_iter().map(Into::into).collect(); self.object_mut().content = Some(v.into()); self } fn add_content(&mut self, content: T) -> &mut Self where T: Into, { 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> { self.object_mut().content.take() } fn delete_content(&mut self) -> &mut Self { self.object_mut().content = None; self } fn set_name(&mut self, name: T) -> &mut Self where T: Into, { self.object_mut().name = Some(name.into().into()); self } fn set_many_names(&mut self, items: I) -> &mut Self where I: IntoIterator, T: Into, { let v: Vec<_> = items.into_iter().map(Into::into).collect(); self.object_mut().name = Some(v.into()); self } fn add_name(&mut self, name: T) -> &mut Self where T: Into, { 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> { self.object_mut().name.take() } fn delete_name(&mut self) -> &mut Self { self.object_mut().name = None; self } fn set_summary(&mut self, summary: T) -> &mut Self where T: Into, { self.object_mut().summary = Some(summary.into().into()); self } fn set_many_summarys(&mut self, items: I) -> &mut Self where I: IntoIterator, T: Into, { let v: Vec<_> = items.into_iter().map(Into::into).collect(); self.object_mut().summary = Some(v.into()); self } fn add_summary(&mut self, summary: T) -> &mut Self where T: Into, { 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> { self.object_mut().summary.take() } fn delete_summary(&mut self) -> &mut Self { self.object_mut().summary = None; self } fn set_url(&mut self, url: T) -> &mut Self where T: Into, { self.object_mut().url = Some(url.into().into()); self } fn set_many_urls(&mut self, items: I) -> &mut Self where I: IntoIterator, T: Into, { let v: Vec<_> = items.into_iter().map(Into::into).collect(); self.object_mut().url = Some(v.into()); self } fn add_url(&mut self, url: T) -> &mut Self where T: Into, { 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> { 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 { self.object_mut().media_type.take() } fn delete_media_type(&mut self) -> &mut Self { self.object_mut().media_type = None; self } fn set_generator(&mut self, generator: T) -> &mut Self where T: Into, { self.object_mut().generator = Some(generator.into().into()); self } fn set_many_generators(&mut self, items: I) -> &mut Self where I: IntoIterator, T: Into, { let v: Vec<_> = items.into_iter().map(Into::into).collect(); self.object_mut().generator = Some(v.into()); self } fn add_generator(&mut self, generator: T) -> &mut Self where T: Into, { 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> { self.object_mut().generator.take() } fn delete_generator(&mut self) -> &mut Self { self.object_mut().generator = None; self } fn set_image(&mut self, image: T) -> &mut Self where T: Into, { self.object_mut().image = Some(image.into().into()); self } fn set_many_images(&mut self, items: I) -> &mut Self where I: IntoIterator, T: Into, { let v: Vec<_> = items.into_iter().map(Into::into).collect(); self.object_mut().image = Some(v.into()); self } fn add_image(&mut self, image: T) -> &mut Self where T: Into, { 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> { self.object_mut().image.take() } fn delete_image(&mut self) -> &mut Self { self.object_mut().image = None; self } fn set_location(&mut self, location: T) -> &mut Self where T: Into, { self.object_mut().location = Some(location.into().into()); self } fn set_many_locations(&mut self, items: I) -> &mut Self where I: IntoIterator, T: Into, { let v: Vec<_> = items.into_iter().map(Into::into).collect(); self.object_mut().location = Some(v.into()); self } fn add_location(&mut self, location: T) -> &mut Self where T: Into, { 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> { self.object_mut().location.take() } fn delete_location(&mut self) -> &mut Self { self.object_mut().location = None; self } fn set_preview(&mut self, preview: T) -> &mut Self where T: Into, { self.object_mut().preview = Some(preview.into().into()); self } fn set_many_previews(&mut self, items: I) -> &mut Self where I: IntoIterator, T: Into, { let v: Vec<_> = items.into_iter().map(Into::into).collect(); self.object_mut().preview = Some(v.into()); self } fn add_preview(&mut self, preview: T) -> &mut Self where T: Into, { 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> { 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 { 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 { 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 { 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 { 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 { self.object_mut().updated.take() } fn delete_updated(&mut self) -> &mut Self { self.object_mut().updated = None; self } fn set_in_reply_to(&mut self, in_reply_to: T) -> &mut Self where T: Into, { self.object_mut().in_reply_to = Some(in_reply_to.into().into()); self } fn set_many_in_reply_tos(&mut self, items: I) -> &mut Self where I: IntoIterator, T: Into, { 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(&mut self, in_reply_to: T) -> &mut Self where T: Into, { 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> { 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(&mut self, replies: T) -> &mut Self where T: Into, { self.object_mut().replies = Some(replies.into().into()); self } fn set_many_repliess(&mut self, items: I) -> &mut Self where I: IntoIterator, T: Into, { let v: Vec<_> = items.into_iter().map(Into::into).collect(); self.object_mut().replies = Some(v.into()); self } fn add_replies(&mut self, replies: T) -> &mut Self where T: Into, { 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> { self.object_mut().replies.take() } fn delete_replies(&mut self) -> &mut Self { self.object_mut().replies = None; self } fn set_to(&mut self, to: T) -> &mut Self where T: Into, { self.object_mut().to = Some(to.into().into()); self } fn set_many_tos(&mut self, items: I) -> &mut Self where I: IntoIterator, T: Into, { let v: Vec<_> = items.into_iter().map(Into::into).collect(); self.object_mut().to = Some(v.into()); self } fn add_to(&mut self, to: T) -> &mut Self where T: Into, { 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> { self.object_mut().to.take() } fn delete_to(&mut self) -> &mut Self { self.object_mut().to = None; self } fn set_bto(&mut self, bto: T) -> &mut Self where T: Into, { self.object_mut().bto = Some(bto.into().into()); self } fn set_many_btos(&mut self, items: I) -> &mut Self where I: IntoIterator, T: Into, { let v: Vec<_> = items.into_iter().map(Into::into).collect(); self.object_mut().bto = Some(v.into()); self } fn add_bto(&mut self, bto: T) -> &mut Self where T: Into, { 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> { self.object_mut().bto.take() } fn delete_bto(&mut self) -> &mut Self { self.object_mut().bto = None; self } fn set_cc(&mut self, cc: T) -> &mut Self where T: Into, { self.object_mut().cc = Some(cc.into().into()); self } fn set_many_ccs(&mut self, items: I) -> &mut Self where I: IntoIterator, T: Into, { let v: Vec<_> = items.into_iter().map(Into::into).collect(); self.object_mut().cc = Some(v.into()); self } fn add_cc(&mut self, cc: T) -> &mut Self where T: Into, { 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> { self.object_mut().cc.take() } fn delete_cc(&mut self) -> &mut Self { self.object_mut().cc = None; self } fn set_bcc(&mut self, bcc: T) -> &mut Self where T: Into, { self.object_mut().bcc = Some(bcc.into().into()); self } fn set_many_bcc(&mut self, items: I) -> &mut Self where I: IntoIterator, T: Into, { let v: Vec<_> = items.into_iter().map(Into::into).collect(); self.object_mut().bcc = Some(v.into()); self } fn add_bcc(&mut self, bcc: T) -> &mut Self where T: Into, { 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> { self.object_mut().bcc.take() } fn delete_bcc(&mut self) -> &mut Self { self.object_mut().bcc = None; self } } pub trait ApObjectRefExt: ApObjectRef { 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> where Inner: 'a, { self.ap_object_ref().upload_media.as_ref() } } pub trait ApObjectMutExt: ApObjectMut { fn set_shares(&mut self, shares: XsdAnyUri) -> &mut Self { self.ap_object_mut().shares = Some(shares); self } fn take_shares(&mut self) -> Option { 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 { self.ap_object_mut().likes.take() } fn delete_likes(&mut self) -> &mut Self { self.ap_object_mut().likes = None; self } fn set_source(&mut self, source: T) -> &mut Self where T: Into, { self.ap_object_mut().source = Some(source.into()); self } fn take_source(&mut self) -> Option { self.ap_object_mut().source.take() } fn delete_source(&mut self) -> &mut Self { self.ap_object_mut().source = None; self } fn set_upload_media(&mut self, upload_media: XsdAnyUri) -> &mut Self { self.ap_object_mut().upload_media = Some(upload_media.into()); self } fn set_many_upload_medias(&mut self, items: I) -> &mut Self where I: IntoIterator, { let v: Vec<_> = items.into_iter().collect(); self.ap_object_mut().upload_media = Some(v.into()); self } fn add_upload_media(&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> { 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(&mut self, float: T) -> &mut Self where T: Into, { self.place_mut().accuracy = Some(float.into()); self } fn take_accuracy(&mut self) -> Option { self.place_mut().accuracy.take() } fn delete_accuracy(&mut self) -> &mut Self { self.place_mut().accuracy = None; self } fn set_altitude(&mut self, float: T) -> &mut Self where T: Into, { self.place_mut().altitude = Some(float.into()); self } fn take_altitude(&mut self) -> Option { self.place_mut().altitude.take() } fn delete_altitude(&mut self) -> &mut Self { self.place_mut().altitude = None; self } fn set_latitude(&mut self, float: T) -> &mut Self where T: Into, { self.place_mut().latitude = Some(float.into()); self } fn take_latitude(&mut self) -> Option { self.place_mut().latitude.take() } fn delete_latitude(&mut self) -> &mut Self { self.place_mut().latitude = None; self } fn set_longitude(&mut self, float: T) -> &mut Self where T: Into, { self.place_mut().longitude = Some(float.into()); self } fn take_longitude(&mut self) -> Option { self.place_mut().longitude.take() } fn delete_longitude(&mut self) -> &mut Self { self.place_mut().longitude = None; self } fn set_radius(&mut self, float: T) -> &mut Self where T: Into, { self.place_mut().radius = Some(float.into()); self } fn take_radius(&mut self) -> Option { self.place_mut().radius.take() } fn delete_radius(&mut self) -> &mut Self { self.place_mut().radius = None; self } fn set_units(&mut self, units: T) -> &mut Self where T: Into, { self.place_mut().units = Some(units.into()); self } fn take_units(&mut self) -> Option { 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(&mut self, describes: T) -> &mut Self where T: Into, { self.profile_mut().describes = Some(describes.into()); self } fn take_describes(&mut self) -> Option { 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> { self.relationship_ref().object.as_ref() } fn relationship(&self) -> Option<&OneOrMany> { self.relationship_ref().relationship.as_ref() } } pub trait RelationshipMutExt: RelationshipMut { fn set_subject(&mut self, subject: T) -> &mut Self where T: Into, { self.relationship_mut().subject = Some(subject.into()); self } fn take_subject(&mut self) -> Option { self.relationship_mut().subject.take() } fn delete_subject(&mut self) -> &mut Self { self.relationship_mut().subject = None; self } fn set_object(&mut self, object: T) -> &mut Self where T: Into, { self.relationship_mut().object = Some(object.into().into()); self } fn set_many_objects(&mut self, items: I) -> &mut Self where I: IntoIterator, T: Into, { let v: Vec<_> = items.into_iter().map(Into::into).collect(); self.relationship_mut().object = Some(v.into()); self } fn add_object(&mut self, object: T) -> &mut Self where T: Into, { 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> { self.relationship_mut().object.take() } fn delete_object(&mut self) -> &mut Self { self.relationship_mut().object = None; self } fn set_relationship(&mut self, relationship: T) -> &mut Self where T: Into, { self.relationship_mut().relationship = Some(relationship.into().into()); self } fn set_many_relationships(&mut self, items: I) -> &mut Self where I: IntoIterator, T: Into, { let v: Vec<_> = items.into_iter().map(Into::into).collect(); self.relationship_mut().relationship = Some(v.into()); self } fn add_relationship(&mut self, relationship: T) -> &mut Self where T: Into, { 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> { 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> { 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(&mut self, former_type: T) -> &mut Self where T: Into, { self.tombstone_mut().former_type = Some(former_type.into().into()); self } fn set_many_former_types(&mut self, items: I) -> &mut Self where I: IntoIterator, T: Into, { let v: Vec<_> = items.into_iter().map(Into::into).collect(); self.tombstone_mut().former_type = Some(v.into()); self } fn add_former_type(&mut self, former_type: T) -> &mut Self where T: Into, { 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> { self.tombstone_mut().former_type.take() } fn delete_former_type(&mut self) -> &mut Self { self.tombstone_mut().former_type = None; self } fn set_deleted(&mut self, deleted: T) -> &mut Self where T: Into, { self.tombstone_mut().deleted = Some(deleted.into()); self } fn take_deleted(&mut self) -> Option { self.tombstone_mut().deleted.take() } fn delete_deleted(&mut self) -> &mut Self { self.tombstone_mut().deleted = None; self } } pub type Article = Object; pub type Audio = Object; pub type Document = Object; pub type Event = Object; pub type Image = Object; pub type Note = Object; pub type Page = Object; pub type Video = Object; #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] #[serde(transparent)] struct IdOrObject(Either>>); #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] #[serde(transparent)] pub struct AnyObject(Either); #[derive(Clone, Debug, Default, serde::Deserialize, serde::Serialize, TypedBuilder)] #[serde(rename_all = "camelCase")] #[builder(doc)] pub struct Object { #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub context: Option>, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub id: Option, #[serde(rename = "type")] #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option))] pub kind: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub attachment: Option>, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub attributed_to: Option>, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub audience: Option>, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub content: Option>, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub name: Option>, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub summary: Option>, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub url: Option>, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option))] pub media_type: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub generator: Option>, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub image: Option>, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub location: Option>, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub preview: Option>, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub start_time: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub end_time: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option))] pub duration: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub published: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub updated: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub in_reply_to: Option>, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub replies: Option>, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub to: Option>, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub bto: Option>, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub cc: Option>, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub bcc: Option>, #[serde(flatten)] #[builder(default)] pub unparsed: Unparsed, } #[derive(Clone, Debug, Default, serde::Deserialize, serde::Serialize, TypedBuilder)] #[serde(rename_all = "camelCase")] #[builder(doc)] pub struct ApObject { #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option))] pub shares: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option))] pub likes: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub source: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub upload_media: Option>, #[serde(flatten)] pub inner: Inner, } #[derive(Debug, Clone, serde::Deserialize, serde::Serialize, TypedBuilder)] #[builder(doc)] pub struct Place { #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub accuracy: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub altitude: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub latitude: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub longitude: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub radius: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option))] pub units: Option, #[serde(flatten)] pub inner: Object, } #[derive(Debug, Clone, serde::Deserialize, serde::Serialize, TypedBuilder)] #[builder(doc)] pub struct Profile { #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub describes: Option, #[serde(flatten)] pub inner: Object, } #[derive(Debug, Clone, serde::Deserialize, serde::Serialize, TypedBuilder)] #[builder(doc)] pub struct Relationship { #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub subject: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub object: Option>, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub relationship: Option>, #[serde(flatten)] pub inner: Object, } #[derive(Debug, Clone, serde::Deserialize, serde::Serialize, TypedBuilder)] #[builder(doc)] pub struct Tombstone { #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub former_type: Option>, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub deleted: Option, #[serde(flatten)] pub inner: Object, } 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> { self.0.as_ref().left().and_then(|l| l.as_object()) } pub fn id(self) -> Option { self.0.left().and_then(|l| l.id()) } pub fn xsd_string(self) -> Option { self.0.right() } pub fn object(self) -> Option> { 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) { 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) -> 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> { self.0.as_ref().right().map(|b| b.as_ref()) } fn id(self) -> Option { self.0.left() } fn object(self) -> Option> { self.0.right().map(|b| *b) } fn from_xsd_any_uri(id: XsdAnyUri) -> Self { IdOrObject(Either::Left(id)) } fn from_object(object: Object) -> Self { IdOrObject(Either::Right(Box::new(object))) } } impl OneOrMany { 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> { self.as_one().and_then(|inner| inner.as_object()) } pub fn single_xsd_any_uri(self) -> Option { self.one().and_then(|inner| inner.id()) } pub fn single_xsd_string(self) -> Option { self.one().and_then(|inner| inner.xsd_string()) } pub fn single_object(self) -> Option> { 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) -> 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) -> &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) -> &mut Self { self.add(AnyObject::from_object(object)) } } impl Object { pub fn solidify(self) -> Result, serde_json::Error> where Kind: serde::de::DeserializeOwned, { self.try_map_kind(serde_json::from_value) } } impl Object { fn extending(mut unparsed: Unparsed) -> Result where Kind: serde::de::DeserializeOwned, { Ok(Object { 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")?, unparsed, }) } fn retracting(self) -> Result 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; 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)?; Ok(unparsed) } pub fn into_generic(self) -> Result, serde_json::Error> where Kind: serde::ser::Serialize, { self.try_map_kind(serde_json::to_value) } pub fn map_kind(self, f: impl Fn(Kind) -> NewKind) -> Object { 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( self, f: impl Fn(Kind) -> Result, ) -> Result, 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(self) -> Result where Extended: Extends, { Extended::extends(self) } } impl ApObject { fn extending(mut inner: Inner) -> Result where Inner: UnparsedMut + traits::Object, { 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 where Inner: UnparsedMut + traits::Object, { 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) -> Result { 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, 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) -> Result { let describes = inner.remove("describes")?; Ok(Profile { describes, inner }) } fn retracting(self) -> Result, serde_json::Error> { let Profile { describes, mut inner, } = self; inner.insert("describes", describes)?; Ok(inner) } } impl Relationship { fn extending(mut inner: Object) -> Result { 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, 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) -> Result { let former_type = inner.remove("formerType")?; let deleted = inner.remove("deleted")?; Ok(Tombstone { former_type, deleted, inner, }) } fn retracting(self) -> Result, serde_json::Error> { let Tombstone { former_type, deleted, mut inner, } = self; inner .insert("formerType", former_type)? .insert("deleted", deleted)?; Ok(inner) } } impl Extends for Object where Kind: serde::de::DeserializeOwned + serde::ser::Serialize, { type Error = serde_json::Error; fn extends(unparsed: Unparsed) -> Result { Self::extending(unparsed) } fn retracts(self) -> Result { self.retracting() } } impl TryFrom for Object where Kind: serde::de::DeserializeOwned, { type Error = serde_json::Error; fn try_from(unparsed: Unparsed) -> Result { Self::extending(unparsed) } } impl TryFrom> for Unparsed where Kind: serde::ser::Serialize, { type Error = serde_json::Error; fn try_from(object: Object) -> Result { object.retracting() } } impl Extends for ApObject where Inner: UnparsedMut + traits::Object, { type Error = serde_json::Error; fn extends(inner: Inner) -> Result { Self::extending(inner) } fn retracts(self) -> Result { self.retracting() } } impl Extends> for Place { type Error = serde_json::Error; fn extends(object: Object) -> Result { Self::extending(object) } fn retracts(self) -> Result, Self::Error> { self.retracting() } } impl TryFrom> for Place { type Error = serde_json::Error; fn try_from(object: Object) -> Result { Self::extending(object) } } impl TryFrom for Object { type Error = serde_json::Error; fn try_from(place: Place) -> Result { place.retracting() } } impl Extends> for Profile { type Error = serde_json::Error; fn extends(object: Object) -> Result { Self::extending(object) } fn retracts(self) -> Result, Self::Error> { self.retracting() } } impl TryFrom> for Profile { type Error = serde_json::Error; fn try_from(object: Object) -> Result { Self::extending(object) } } impl TryFrom for Object { type Error = serde_json::Error; fn try_from(profile: Profile) -> Result { profile.retracting() } } impl Extends> for Relationship { type Error = serde_json::Error; fn extends(object: Object) -> Result { Self::extending(object) } fn retracts(self) -> Result, Self::Error> { self.retracting() } } impl TryFrom> for Relationship { type Error = serde_json::Error; fn try_from(object: Object) -> Result { Self::extending(object) } } impl TryFrom for Object { type Error = serde_json::Error; fn try_from(relationship: Relationship) -> Result { relationship.retracting() } } impl Extends> for Tombstone { type Error = serde_json::Error; fn extends(object: Object) -> Result { Self::extending(object) } fn retracts(self) -> Result, Self::Error> { self.retracting() } } impl TryFrom> for Tombstone { type Error = serde_json::Error; fn try_from(object: Object) -> Result { Self::extending(object) } } impl TryFrom for Object { type Error = serde_json::Error; fn try_from(tombstone: Tombstone) -> Result { tombstone.retracting() } } impl UnparsedMut for Object { fn unparsed_mut(&mut self) -> &mut Unparsed { &mut self.unparsed } } impl UnparsedMut for ApObject where Inner: UnparsedMut, { fn unparsed_mut(&mut self) -> &mut Unparsed { self.inner.unparsed_mut() } } impl UnparsedMut for Place { fn unparsed_mut(&mut self) -> &mut Unparsed { self.inner.unparsed_mut() } } impl UnparsedMut for Profile { fn unparsed_mut(&mut self) -> &mut Unparsed { self.inner.unparsed_mut() } } impl UnparsedMut for Relationship { fn unparsed_mut(&mut self) -> &mut Unparsed { self.inner.unparsed_mut() } } impl UnparsedMut for Tombstone { fn unparsed_mut(&mut self) -> &mut Unparsed { self.inner.unparsed_mut() } } impl From> for AnyObject { fn from(o: Object) -> Self { Self::from_object(o) } } impl From for AnyObject { fn from(id: XsdAnyUri) -> Self { Self::from_xsd_any_uri(id) } } impl From for AnyObject { fn from(xsd_string: XsdString) -> Self { Self::from_xsd_string(xsd_string) } } impl From> for OneOrMany { fn from(object: Object) -> Self { Self::from_object(object) } } impl From for OneOrMany { fn from(xsd_any_uri: XsdAnyUri) -> Self { Self::from_xsd_any_uri(xsd_any_uri) } } impl From for OneOrMany { fn from(xsd_string: XsdString) -> Self { Self::from_xsd_string(xsd_string) } } impl traits::Base for Object {} impl traits::Object for Object {} impl traits::Base for ApObject where Inner: traits::Base {} impl traits::Object for ApObject 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 ObjectRefExt for T where T: ObjectRef {} impl ObjectMutExt for T where T: ObjectMut {} impl ApObjectRefExt for T where T: ApObjectRef {} impl ApObjectMutExt for T where T: ApObjectMut {} impl PlaceRefExt for T where T: PlaceRef {} impl PlaceMutExt for T where T: PlaceMut {} impl ProfileRefExt for T where T: ProfileRef {} impl ProfileMutExt for T where T: ProfileMut {} impl RelationshipRefExt for T where T: RelationshipRef {} impl RelationshipMutExt for T where T: RelationshipMut {} impl TombstoneRefExt for T where T: TombstoneRef {} impl TombstoneMutExt for T where T: TombstoneMut {} impl ObjectRef for Object { fn object_ref(&self) -> &Object { self } } impl ObjectMut for Object { fn object_mut(&mut self) -> &mut Object { self } } impl ObjectRef for ApObject where Inner: ObjectRef, { fn object_ref(&self) -> &Object { self.inner.object_ref() } } impl ObjectMut for ApObject where Inner: ObjectMut, { fn object_mut(&mut self) -> &mut Object { self.inner.object_mut() } } impl ApObjectRef for ApObject where Inner: traits::Object, { fn ap_object_ref(&self) -> &ApObject { self } } impl ApObjectMut for ApObject where Inner: traits::Object, { fn ap_object_mut(&mut self) -> &mut ApObject { self } } impl PlaceRef for ApObject where Inner: PlaceRef, { fn place_ref(&self) -> &Place { self.inner.place_ref() } } impl PlaceMut for ApObject where Inner: PlaceMut, { fn place_mut(&mut self) -> &mut Place { self.inner.place_mut() } } impl ProfileRef for ApObject where Inner: ProfileRef, { fn profile_ref(&self) -> &Profile { self.inner.profile_ref() } } impl ProfileMut for ApObject where Inner: ProfileMut, { fn profile_mut(&mut self) -> &mut Profile { self.inner.profile_mut() } } impl RelationshipRef for ApObject where Inner: RelationshipRef, { fn relationship_ref(&self) -> &Relationship { self.inner.relationship_ref() } } impl RelationshipMut for ApObject where Inner: RelationshipMut, { fn relationship_mut(&mut self) -> &mut Relationship { self.inner.relationship_mut() } } impl TombstoneRef for ApObject where Inner: TombstoneRef, { fn tombstone_ref(&self) -> &Tombstone { self.inner.tombstone_ref() } } impl TombstoneMut for ApObject 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 } }