use crate::{ base::{AnyBase, AsBase, Base, Extends}, markers, object::{ApObject, AsObject, Object}, primitives::OneOrMany, unparsed::{Unparsed, UnparsedMut, UnparsedMutExt}, }; use std::convert::TryFrom; use typed_builder::TypedBuilder; pub mod kind { pub use activitystreams::activity::kind::*; } use self::kind::*; pub trait AsActivity: markers::Activity { fn activity_ref(&self) -> &Activity; fn activity_mut(&mut self) -> &mut Activity; } pub trait ActorAndObjectRef: markers::Activity { fn actor_field_ref(&self) -> &OneOrMany; fn object_field_ref(&self) -> &OneOrMany; fn actor_field_mut(&mut self) -> &mut OneOrMany; fn object_field_mut(&mut self) -> &mut OneOrMany; } pub trait TargetRef: markers::Activity { fn target_field_ref(&self) -> &OneOrMany; fn target_field_mut(&mut self) -> &mut OneOrMany; } pub trait OriginRef: markers::Activity { fn origin_field_ref(&self) -> &OneOrMany; fn origin_field_mut(&mut self) -> &mut OneOrMany; } pub trait OptTargetRef: markers::Activity { fn target_field_ref(&self) -> &Option>; fn target_field_mut(&mut self) -> &mut Option>; } pub trait OptOriginRef: markers::Activity { fn origin_field_ref(&self) -> &Option>; fn origin_field_mut(&mut self) -> &mut Option>; } pub trait AsQuestion: markers::Activity { fn question_ref(&self) -> &Question; fn question_mut(&mut self) -> &mut Question; } pub trait ActivityExt: AsActivity { fn result<'a>(&'a self) -> Option<&'a OneOrMany> where Kind: 'a, { self.activity_ref().result.as_ref() } fn set_result(&mut self, result: T) -> &mut Self where T: Into, { self.activity_mut().result = Some(result.into().into()); self } fn set_many_results(&mut self, items: I) -> &mut Self where I: IntoIterator, T: Into, { let v: Vec<_> = items.into_iter().map(Into::into).collect(); self.activity_mut().result = Some(v.into()); self } fn add_result(&mut self, result: T) -> &mut Self where T: Into, { let c = match self.activity_mut().result.take() { Some(mut c) => { c.add(result.into()); c } None => vec![result.into()].into(), }; self.activity_mut().result = Some(c); self } fn take_result(&mut self) -> Option> { self.activity_mut().result.take() } fn delete_result(&mut self) -> &mut Self { self.activity_mut().result = None; self } fn instrument<'a>(&'a self) -> Option<&'a OneOrMany> where Kind: 'a, { self.activity_ref().instrument.as_ref() } fn set_instrument(&mut self, instrument: T) -> &mut Self where T: Into, { self.activity_mut().instrument = Some(instrument.into().into()); self } fn set_many_instruments(&mut self, items: I) -> &mut Self where I: IntoIterator, T: Into, { let v: Vec<_> = items.into_iter().map(Into::into).collect(); self.activity_mut().instrument = Some(v.into()); self } fn add_instrument(&mut self, instrument: T) -> &mut Self where T: Into, { let c = match self.activity_mut().instrument.take() { Some(mut c) => { c.add(instrument.into()); c } None => vec![instrument.into()].into(), }; self.activity_mut().instrument = Some(c); self } fn take_instrument(&mut self) -> Option> { self.activity_mut().instrument.take() } fn delete_instrument(&mut self) -> &mut Self { self.activity_mut().instrument = None; self } } pub trait ActorAndObjectRefExt: ActorAndObjectRef { fn actor(&self) -> &OneOrMany { self.actor_field_ref() } fn set_actor(&mut self, actor: T) -> &mut Self where T: Into, { *self.actor_field_mut() = actor.into().into(); self } fn set_many_actors(&mut self, items: I) -> &mut Self where I: IntoIterator, T: Into, { let v: Vec<_> = items.into_iter().map(Into::into).collect(); *self.actor_field_mut() = v.into(); self } fn add_actor(&mut self, actor: T) -> &mut Self where T: Into, { self.actor_field_mut().add(actor.into()); self } fn object(&self) -> &OneOrMany { self.object_field_ref() } fn set_object(&mut self, object: T) -> &mut Self where T: Into, { *self.object_field_mut() = 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.object_field_mut() = v.into(); self } fn add_object(&mut self, object: T) -> &mut Self where T: Into, { self.object_field_mut().add(object.into()); self } } pub trait TargetRefExt: TargetRef { fn target(&self) -> &OneOrMany { self.target_field_ref() } fn set_target(&mut self, target: T) -> &mut Self where T: Into, { *self.target_field_mut() = target.into().into(); self } fn set_many_targets(&mut self, items: I) -> &mut Self where I: IntoIterator, T: Into, { let v: Vec<_> = items.into_iter().map(Into::into).collect(); *self.target_field_mut() = v.into(); self } fn add_target(&mut self, target: T) -> &mut Self where T: Into, { self.target_field_mut().add(target.into()); self } } pub trait OriginRefExt: OriginRef { fn origin(&self) -> &OneOrMany { self.origin_field_ref() } fn set_origin(&mut self, origin: T) -> &mut Self where T: Into, { *self.origin_field_mut() = origin.into().into(); self } fn set_many_origins(&mut self, items: I) -> &mut Self where I: IntoIterator, T: Into, { let v: Vec<_> = items.into_iter().map(Into::into).collect(); *self.origin_field_mut() = v.into(); self } fn add_origin(&mut self, origin: T) -> &mut Self where T: Into, { self.origin_field_mut().add(origin.into()); self } } pub trait OptTargetRefExt: OptTargetRef { fn target(&self) -> Option<&OneOrMany> { self.target_field_ref().as_ref() } fn set_target(&mut self, target: T) -> &mut Self where T: Into, { *self.target_field_mut() = Some(target.into().into()); self } fn set_many_targets(&mut self, items: I) -> &mut Self where I: IntoIterator, T: Into, { let v: Vec<_> = items.into_iter().map(Into::into).collect(); *self.target_field_mut() = Some(v.into()); self } fn add_target(&mut self, target: T) -> &mut Self where T: Into, { let c = match self.target_field_mut().take() { Some(mut c) => { c.add(target.into()); c } None => vec![target.into()].into(), }; *self.target_field_mut() = Some(c); self } fn take_target(&mut self) -> Option> { self.target_field_mut().take() } fn delete_target(&mut self) -> &mut Self { *self.target_field_mut() = None; self } } pub trait OptOriginRefExt: OptOriginRef { fn origin(&self) -> Option<&OneOrMany> { self.origin_field_ref().as_ref() } fn set_origin(&mut self, origin: T) -> &mut Self where T: Into, { *self.origin_field_mut() = Some(origin.into().into()); self } fn set_many_origins(&mut self, items: I) -> &mut Self where I: IntoIterator, T: Into, { let v: Vec<_> = items.into_iter().map(Into::into).collect(); *self.origin_field_mut() = Some(v.into()); self } fn add_origin(&mut self, origin: T) -> &mut Self where T: Into, { let c = match self.origin_field_mut().take() { Some(mut c) => { c.add(origin.into()); c } None => vec![origin.into()].into(), }; *self.origin_field_mut() = Some(c); self } fn take_origin(&mut self) -> Option> { self.origin_field_mut().take() } fn delete_origin(&mut self) -> &mut Self { *self.origin_field_mut() = None; self } } pub trait QuestionExt: AsQuestion { fn one_of(&self) -> Option<&OneOrMany> { self.question_ref().one_of.as_ref() } fn any_of(&self) -> Option<&OneOrMany> { self.question_ref().any_of.as_ref() } fn set_one_of(&mut self, one_of: T) -> &mut Self where T: Into, { self.question_mut().one_of = Some(one_of.into().into()); self } fn set_many_one_ofs(&mut self, items: I) -> &mut Self where I: IntoIterator, T: Into, { let v: Vec<_> = items.into_iter().map(Into::into).collect(); self.question_mut().one_of = Some(v.into()); self } fn add_one_of(&mut self, one_of: T) -> &mut Self where T: Into, { let v = match self.question_mut().one_of.take() { Some(mut v) => { v.add(one_of.into()); v } None => vec![one_of.into()].into(), }; self.question_mut().one_of = Some(v); self } fn take_one_of(&mut self) -> Option> { self.question_mut().one_of.take() } fn delete_one_of(&mut self) -> &mut Self { self.question_mut().one_of = None; self } fn set_any_of(&mut self, any_of: T) -> &mut Self where T: Into, { self.question_mut().any_of = Some(any_of.into().into()); self } fn set_many_any_ofs(&mut self, items: I) -> &mut Self where I: IntoIterator, T: Into, { let v: Vec<_> = items.into_iter().map(Into::into).collect(); self.question_mut().any_of = Some(v.into()); self } fn add_any_of(&mut self, any_of: T) -> &mut Self where T: Into, { let v = match self.question_mut().any_of.take() { Some(mut v) => { v.add(any_of.into()); v } None => vec![any_of.into()].into(), }; self.question_mut().any_of = Some(v); self } fn take_any_of(&mut self) -> Option> { self.question_mut().any_of.take() } fn delete_any_of(&mut self) -> &mut Self { self.question_mut().any_of = None; self } } pub type Accept = ActorAndObject; pub type Add = ActorAndObject; pub type Block = ActorAndObject; pub type Create = ActorAndObject; pub type Dislike = ActorAndObject; pub type Flag = ActorAndObject; pub type Follow = ActorAndObject; pub type Ignore = ActorAndObject; pub type Join = ActorAndObject; pub type Leave = ActorAndObject; pub type Like = ActorAndObject; pub type Listen = ActorAndObject; pub type Read = ActorAndObject; pub type Reject = ActorAndObject; pub type TentativeAccept = ActorAndObject; pub type TentativeReject = ActorAndObject; pub type Undo = ActorAndObject; pub type Update = ActorAndObject; pub type View = ActorAndObject; pub type Announce = ActorAndObjectOptTarget; pub type Offer = ActorAndObjectOptTarget; pub type Move = ActorAndObjectOptOriginAndTarget; pub type Remove = ActorAndObjectOptOriginAndTarget; #[derive(Clone, Debug, Default, serde::Deserialize, serde::Serialize, TypedBuilder)] #[serde(rename_all = "camelCase")] #[builder(doc)] pub struct Activity { #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub result: Option>, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub instrument: Option>, #[serde(flatten)] pub inner: Object, } #[derive(Debug, Clone, serde::Deserialize, serde::Serialize, TypedBuilder)] #[serde(rename_all = "camelCase")] #[builder(doc)] pub struct ActorAndObject { #[builder(setter(into))] pub actor: OneOrMany, #[builder(setter(into))] pub object: OneOrMany, #[serde(flatten)] pub inner: Activity, } #[derive(Debug, Clone, serde::Deserialize, serde::Serialize, TypedBuilder)] #[serde(rename_all = "camelCase")] #[builder(doc)] pub struct Arrive { #[builder(setter(into))] pub actor: OneOrMany, #[builder(setter(into))] pub origin: OneOrMany, #[serde(flatten)] pub inner: Activity, } #[derive(Debug, Clone, serde::Deserialize, serde::Serialize, TypedBuilder)] #[serde(rename_all = "camelCase")] #[builder(doc)] pub struct Invite { #[builder(setter(into))] pub actor: OneOrMany, #[builder(setter(into))] pub object: OneOrMany, #[builder(setter(into))] pub target: OneOrMany, #[serde(flatten)] pub inner: Activity, } #[derive(Debug, Clone, serde::Deserialize, serde::Serialize, TypedBuilder)] #[serde(rename_all = "camelCase")] #[builder(doc)] pub struct Delete { #[builder(setter(into))] pub actor: OneOrMany, #[builder(setter(into))] pub object: OneOrMany, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub origin: Option>, #[serde(flatten)] pub inner: Activity, } #[derive(Debug, Clone, serde::Deserialize, serde::Serialize, TypedBuilder)] #[serde(rename_all = "camelCase")] #[builder(doc)] pub struct ActorAndObjectOptOriginAndTarget { #[builder(setter(into))] pub actor: OneOrMany, #[builder(setter(into))] pub object: OneOrMany, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub origin: Option>, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub target: Option>, #[serde(flatten)] pub inner: Activity, } #[derive(Debug, Clone, serde::Deserialize, serde::Serialize, TypedBuilder)] #[serde(rename_all = "camelCase")] #[builder(doc)] pub struct ActorAndObjectOptTarget { #[builder(setter(into))] pub actor: OneOrMany, #[builder(setter(into))] pub object: OneOrMany, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub target: Option>, #[serde(flatten)] pub inner: Activity, } #[derive(Debug, Clone, serde::Deserialize, serde::Serialize, TypedBuilder)] #[serde(rename_all = "camelCase")] #[builder(doc)] pub struct Travel { #[builder(setter(into))] pub actor: OneOrMany, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub origin: Option>, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub target: Option>, #[serde(flatten)] pub inner: Activity, } #[derive(Debug, Clone, serde::Deserialize, serde::Serialize, TypedBuilder)] #[serde(rename_all = "camelCase")] #[builder(doc)] pub struct Question { #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub one_of: Option>, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option, into))] pub any_of: Option>, #[serde(flatten)] pub inner: Activity, } impl Activity { fn extending(mut inner: Object) -> Result { let result = inner.remove("result")?; let instrument = inner.remove("instrument")?; Ok(Activity { result, instrument, inner, }) } fn retracting(self) -> Result, serde_json::Error> { let Activity { result, instrument, mut inner, } = self; inner .insert("result", result)? .insert("instrument", instrument)?; Ok(inner) } } impl ActorAndObject { fn extending(object: Object) -> Result { let mut inner = Activity::extending(object)?; let actor = inner.remove("actor")?; let object = inner.remove("object")?; Ok(ActorAndObject { actor, object, inner, }) } fn retracting(self) -> Result, serde_json::Error> { let ActorAndObject { actor, object, mut inner, } = self; inner.insert("actor", actor)?.insert("object", object)?; inner.retracting() } } impl Arrive { fn extending(object: Object) -> Result { let mut inner = Activity::extending(object)?; let actor = inner.remove("actor")?; let origin = inner.remove("origin")?; Ok(Arrive { actor, origin, inner, }) } fn retracting(self) -> Result, serde_json::Error> { let Arrive { actor, origin, mut inner, } = self; inner.insert("actor", actor)?.insert("origin", origin)?; inner.retracting() } } impl Invite { fn extending(object: Object) -> Result { let mut inner = Activity::extending(object)?; let actor = inner.remove("actor")?; let object = inner.remove("object")?; let target = inner.remove("target")?; Ok(Invite { actor, object, target, inner, }) } fn retracting(self) -> Result, serde_json::Error> { let Invite { actor, object, target, mut inner, } = self; inner .insert("actor", actor)? .insert("object", object)? .insert("target", target)?; inner.retracting() } } impl Delete { fn extending(object: Object) -> Result { let mut inner = Activity::extending(object)?; let actor = inner.remove("actor")?; let object = inner.remove("object")?; let origin = inner.remove("origin")?; Ok(Delete { actor, object, origin, inner, }) } fn retracting(self) -> Result, serde_json::Error> { let Delete { actor, object, origin, mut inner, } = self; inner .insert("actor", actor)? .insert("object", object)? .insert("origin", origin)?; inner.retracting() } } impl ActorAndObjectOptOriginAndTarget { fn extending(object: Object) -> Result { let mut inner = Activity::extending(object)?; let actor = inner.remove("actor")?; let object = inner.remove("object")?; let origin = inner.remove("origin")?; let target = inner.remove("target")?; Ok(ActorAndObjectOptOriginAndTarget { actor, object, origin, target, inner, }) } fn retracting(self) -> Result, serde_json::Error> { let ActorAndObjectOptOriginAndTarget { actor, object, origin, target, mut inner, } = self; inner .insert("actor", actor)? .insert("object", object)? .insert("origin", origin)? .insert("target", target)?; inner.retracting() } } impl ActorAndObjectOptTarget { fn extending(object: Object) -> Result { let mut inner = Activity::extending(object)?; let actor = inner.remove("actor")?; let object = inner.remove("object")?; let target = inner.remove("target")?; Ok(ActorAndObjectOptTarget { actor, object, target, inner, }) } fn retracting(self) -> Result, serde_json::Error> { let ActorAndObjectOptTarget { actor, object, target, mut inner, } = self; inner .insert("actor", actor)? .insert("object", object)? .insert("target", target)?; inner.retracting() } } impl Travel { fn extending(object: Object) -> Result { let mut inner = Activity::extending(object)?; let actor = inner.remove("actor")?; let origin = inner.remove("origin")?; let target = inner.remove("target")?; Ok(Travel { actor, origin, target, inner, }) } fn retracting(self) -> Result, serde_json::Error> { let Travel { actor, origin, target, mut inner, } = self; inner .insert("actor", actor)? .insert("origin", origin)? .insert("target", target)?; inner.retracting() } } impl Question { fn extending(object: Object) -> Result { let mut inner = Activity::extending(object)?; let one_of = inner.remove("oneOf")?; let any_of = inner.remove("anyOf")?; Ok(Question { one_of, any_of, inner, }) } fn retracting(self) -> Result, serde_json::Error> { let Question { one_of, any_of, mut inner, } = self; inner.insert("oneOf", one_of)?.insert("anyOf", any_of)?; inner.retracting() } } impl markers::Base for Activity {} impl markers::Object for Activity {} impl markers::Activity for Activity {} impl markers::Base for ActorAndObject {} impl markers::Object for ActorAndObject {} impl markers::Activity for ActorAndObject {} impl markers::Base for ActorAndObjectOptTarget {} impl markers::Object for ActorAndObjectOptTarget {} impl markers::Activity for ActorAndObjectOptTarget {} impl markers::Base for ActorAndObjectOptOriginAndTarget {} impl markers::Object for ActorAndObjectOptOriginAndTarget {} impl markers::Activity for ActorAndObjectOptOriginAndTarget {} impl markers::Base for Arrive {} impl markers::Object for Arrive {} impl markers::Activity for Arrive {} impl markers::IntransitiveActivity for Arrive {} impl markers::Base for Invite {} impl markers::Object for Invite {} impl markers::Activity for Invite {} impl markers::Base for Delete {} impl markers::Object for Delete {} impl markers::Activity for Delete {} impl markers::Base for Travel {} impl markers::Object for Travel {} impl markers::Activity for Travel {} impl markers::IntransitiveActivity for Travel {} impl markers::Base for Question {} impl markers::Object for Question {} impl markers::Activity for Question {} impl markers::IntransitiveActivity for Question {} impl markers::Activity for ApObject where Inner: markers::Activity {} impl markers::IntransitiveActivity for ApObject where Inner: markers::IntransitiveActivity { } impl Extends for Activity where Kind: serde::de::DeserializeOwned + serde::ser::Serialize, { type Error = serde_json::Error; fn extends(base: Base) -> Result { let inner = Object::extends(base)?; Self::extending(inner) } fn retracts(self) -> Result, Self::Error> { let inner = self.retracting()?; inner.retracts() } } impl TryFrom> for Activity { 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(activity: Activity) -> Result { activity.retracting() } } impl Extends for ActorAndObject where Kind: serde::de::DeserializeOwned + serde::ser::Serialize, { type Error = serde_json::Error; fn extends(base: Base) -> Result { let inner = Object::extends(base)?; Self::extending(inner) } fn retracts(self) -> Result, Self::Error> { let inner = self.retracting()?; inner.retracts() } } impl TryFrom> for ActorAndObject { 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(activity: ActorAndObject) -> Result { activity.retracting() } } impl Extends for Arrive { type Error = serde_json::Error; fn extends(base: Base) -> Result { let inner = Object::extends(base)?; Self::extending(inner) } fn retracts(self) -> Result, Self::Error> { let inner = self.retracting()?; inner.retracts() } } impl TryFrom> for Arrive { 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(arrive: Arrive) -> Result { arrive.retracting() } } impl Extends for Invite { type Error = serde_json::Error; fn extends(base: Base) -> Result { let inner = Object::extends(base)?; Self::extending(inner) } fn retracts(self) -> Result, Self::Error> { let inner = self.retracting()?; inner.retracts() } } impl TryFrom> for Invite { 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(invite: Invite) -> Result { invite.retracting() } } impl Extends for Delete { type Error = serde_json::Error; fn extends(base: Base) -> Result { let inner = Object::extends(base)?; Self::extending(inner) } fn retracts(self) -> Result, Self::Error> { let inner = self.retracting()?; inner.retracts() } } impl TryFrom> for Delete { 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(delete: Delete) -> Result { delete.retracting() } } impl Extends for ActorAndObjectOptOriginAndTarget where Kind: serde::de::DeserializeOwned + serde::ser::Serialize, { type Error = serde_json::Error; fn extends(base: Base) -> Result { let inner = Object::extends(base)?; Self::extending(inner) } fn retracts(self) -> Result, Self::Error> { let inner = self.retracting()?; inner.retracts() } } impl TryFrom> for ActorAndObjectOptOriginAndTarget { 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(activity: ActorAndObjectOptOriginAndTarget) -> Result { activity.retracting() } } impl Extends for ActorAndObjectOptTarget where Kind: serde::de::DeserializeOwned + serde::ser::Serialize, { type Error = serde_json::Error; fn extends(base: Base) -> Result { let inner = Object::extends(base)?; Self::extending(inner) } fn retracts(self) -> Result, Self::Error> { let inner = self.retracting()?; inner.retracts() } } impl TryFrom> for ActorAndObjectOptTarget { 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(activity: ActorAndObjectOptTarget) -> Result { activity.retracting() } } impl Extends for Travel { type Error = serde_json::Error; fn extends(base: Base) -> Result { let inner = Object::extends(base)?; Self::extending(inner) } fn retracts(self) -> Result, Self::Error> { let inner = self.retracting()?; inner.retracts() } } impl TryFrom> for Travel { 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(travel: Travel) -> Result { travel.retracting() } } impl Extends for Question { type Error = serde_json::Error; fn extends(base: Base) -> Result { let inner = Object::extends(base)?; Self::extending(inner) } fn retracts(self) -> Result, Self::Error> { let inner = self.retracting()?; inner.retracts() } } impl TryFrom> for Question { 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(question: Question) -> Result { question.retracting() } } impl UnparsedMut for Activity { fn unparsed_mut(&mut self) -> &mut Unparsed { self.inner.unparsed_mut() } } impl UnparsedMut for ActorAndObject { fn unparsed_mut(&mut self) -> &mut Unparsed { self.inner.unparsed_mut() } } impl UnparsedMut for Arrive { fn unparsed_mut(&mut self) -> &mut Unparsed { self.inner.unparsed_mut() } } impl UnparsedMut for Invite { fn unparsed_mut(&mut self) -> &mut Unparsed { self.inner.unparsed_mut() } } impl UnparsedMut for Delete { fn unparsed_mut(&mut self) -> &mut Unparsed { self.inner.unparsed_mut() } } impl UnparsedMut for ActorAndObjectOptOriginAndTarget { fn unparsed_mut(&mut self) -> &mut Unparsed { self.inner.unparsed_mut() } } impl UnparsedMut for ActorAndObjectOptTarget { fn unparsed_mut(&mut self) -> &mut Unparsed { self.inner.unparsed_mut() } } impl UnparsedMut for Travel { fn unparsed_mut(&mut self) -> &mut Unparsed { self.inner.unparsed_mut() } } impl UnparsedMut for Question { fn unparsed_mut(&mut self) -> &mut Unparsed { self.inner.unparsed_mut() } } impl AsBase for Activity { fn base_ref(&self) -> &Base { self.inner.base_ref() } fn base_mut(&mut self) -> &mut Base { self.inner.base_mut() } } impl AsObject for Activity { fn object_ref(&self) -> &Object { &self.inner } fn object_mut(&mut self) -> &mut Object { &mut self.inner } } impl AsActivity for Activity { fn activity_ref(&self) -> &Activity { self } fn activity_mut(&mut self) -> &mut Activity { self } } impl AsBase for ActorAndObject { fn base_ref(&self) -> &Base { self.inner.base_ref() } fn base_mut(&mut self) -> &mut Base { self.inner.base_mut() } } impl AsObject for ActorAndObject { fn object_ref(&self) -> &Object { self.inner.object_ref() } fn object_mut(&mut self) -> &mut Object { self.inner.object_mut() } } impl AsActivity for ActorAndObject { fn activity_ref(&self) -> &Activity { &self.inner } fn activity_mut(&mut self) -> &mut Activity { &mut self.inner } } impl ActorAndObjectRef for ActorAndObject { fn actor_field_ref(&self) -> &OneOrMany { &self.actor } fn object_field_ref(&self) -> &OneOrMany { &self.object } fn actor_field_mut(&mut self) -> &mut OneOrMany { &mut self.actor } fn object_field_mut(&mut self) -> &mut OneOrMany { &mut self.object } } impl AsBase for ActorAndObjectOptTarget { fn base_ref(&self) -> &Base { self.inner.base_ref() } fn base_mut(&mut self) -> &mut Base { self.inner.base_mut() } } impl AsObject for ActorAndObjectOptTarget { fn object_ref(&self) -> &Object { self.inner.object_ref() } fn object_mut(&mut self) -> &mut Object { self.inner.object_mut() } } impl AsActivity for ActorAndObjectOptTarget { fn activity_ref(&self) -> &Activity { &self.inner } fn activity_mut(&mut self) -> &mut Activity { &mut self.inner } } impl ActorAndObjectRef for ActorAndObjectOptTarget { fn actor_field_ref(&self) -> &OneOrMany { &self.actor } fn object_field_ref(&self) -> &OneOrMany { &self.object } fn actor_field_mut(&mut self) -> &mut OneOrMany { &mut self.actor } fn object_field_mut(&mut self) -> &mut OneOrMany { &mut self.object } } impl OptTargetRef for ActorAndObjectOptTarget { fn target_field_ref(&self) -> &Option> { &self.target } fn target_field_mut(&mut self) -> &mut Option> { &mut self.target } } impl AsBase for ActorAndObjectOptOriginAndTarget { fn base_ref(&self) -> &Base { self.inner.base_ref() } fn base_mut(&mut self) -> &mut Base { self.inner.base_mut() } } impl AsObject for ActorAndObjectOptOriginAndTarget { fn object_ref(&self) -> &Object { self.inner.object_ref() } fn object_mut(&mut self) -> &mut Object { self.inner.object_mut() } } impl AsActivity for ActorAndObjectOptOriginAndTarget { fn activity_ref(&self) -> &Activity { &self.inner } fn activity_mut(&mut self) -> &mut Activity { &mut self.inner } } impl ActorAndObjectRef for ActorAndObjectOptOriginAndTarget { fn actor_field_ref(&self) -> &OneOrMany { &self.actor } fn object_field_ref(&self) -> &OneOrMany { &self.object } fn actor_field_mut(&mut self) -> &mut OneOrMany { &mut self.actor } fn object_field_mut(&mut self) -> &mut OneOrMany { &mut self.object } } impl OptTargetRef for ActorAndObjectOptOriginAndTarget { fn target_field_ref(&self) -> &Option> { &self.target } fn target_field_mut(&mut self) -> &mut Option> { &mut self.target } } impl OptOriginRef for ActorAndObjectOptOriginAndTarget { fn origin_field_ref(&self) -> &Option> { &self.origin } fn origin_field_mut(&mut self) -> &mut Option> { &mut self.origin } } impl AsBase for Arrive { fn base_ref(&self) -> &Base { self.inner.base_ref() } fn base_mut(&mut self) -> &mut Base { self.inner.base_mut() } } impl AsObject for Arrive { fn object_ref(&self) -> &Object { self.inner.object_ref() } fn object_mut(&mut self) -> &mut Object { self.inner.object_mut() } } impl AsActivity for Arrive { fn activity_ref(&self) -> &Activity { &self.inner } fn activity_mut(&mut self) -> &mut Activity { &mut self.inner } } impl OriginRef for Arrive { fn origin_field_ref(&self) -> &OneOrMany { &self.origin } fn origin_field_mut(&mut self) -> &mut OneOrMany { &mut self.origin } } impl AsBase for Invite { fn base_ref(&self) -> &Base { self.inner.base_ref() } fn base_mut(&mut self) -> &mut Base { self.inner.base_mut() } } impl AsObject for Invite { fn object_ref(&self) -> &Object { self.inner.object_ref() } fn object_mut(&mut self) -> &mut Object { self.inner.object_mut() } } impl AsActivity for Invite { fn activity_ref(&self) -> &Activity { &self.inner } fn activity_mut(&mut self) -> &mut Activity { &mut self.inner } } impl ActorAndObjectRef for Invite { fn actor_field_ref(&self) -> &OneOrMany { &self.actor } fn object_field_ref(&self) -> &OneOrMany { &self.object } fn actor_field_mut(&mut self) -> &mut OneOrMany { &mut self.actor } fn object_field_mut(&mut self) -> &mut OneOrMany { &mut self.object } } impl TargetRef for Invite { fn target_field_ref(&self) -> &OneOrMany { &self.target } fn target_field_mut(&mut self) -> &mut OneOrMany { &mut self.target } } impl AsBase for Delete { fn base_ref(&self) -> &Base { self.inner.base_ref() } fn base_mut(&mut self) -> &mut Base { self.inner.base_mut() } } impl AsObject for Delete { fn object_ref(&self) -> &Object { self.inner.object_ref() } fn object_mut(&mut self) -> &mut Object { self.inner.object_mut() } } impl AsActivity for Delete { fn activity_ref(&self) -> &Activity { &self.inner } fn activity_mut(&mut self) -> &mut Activity { &mut self.inner } } impl ActorAndObjectRef for Delete { fn actor_field_ref(&self) -> &OneOrMany { &self.actor } fn object_field_ref(&self) -> &OneOrMany { &self.object } fn actor_field_mut(&mut self) -> &mut OneOrMany { &mut self.actor } fn object_field_mut(&mut self) -> &mut OneOrMany { &mut self.object } } impl OptOriginRef for Delete { fn origin_field_ref(&self) -> &Option> { &self.origin } fn origin_field_mut(&mut self) -> &mut Option> { &mut self.origin } } impl AsBase for Travel { fn base_ref(&self) -> &Base { self.inner.base_ref() } fn base_mut(&mut self) -> &mut Base { self.inner.base_mut() } } impl AsObject for Travel { fn object_ref(&self) -> &Object { self.inner.object_ref() } fn object_mut(&mut self) -> &mut Object { self.inner.object_mut() } } impl AsActivity for Travel { fn activity_ref(&self) -> &Activity { self.inner.activity_ref() } fn activity_mut(&mut self) -> &mut Activity { self.inner.activity_mut() } } impl OptTargetRef for Travel { fn target_field_ref(&self) -> &Option> { &self.target } fn target_field_mut(&mut self) -> &mut Option> { &mut self.target } } impl OptOriginRef for Travel { fn origin_field_ref(&self) -> &Option> { &self.origin } fn origin_field_mut(&mut self) -> &mut Option> { &mut self.origin } } impl AsBase for Question { fn base_ref(&self) -> &Base { self.inner.base_ref() } fn base_mut(&mut self) -> &mut Base { self.inner.base_mut() } } impl AsObject for Question { fn object_ref(&self) -> &Object { self.inner.object_ref() } fn object_mut(&mut self) -> &mut Object { self.inner.object_mut() } } impl AsActivity for Question { fn activity_ref(&self) -> &Activity { &self.inner } fn activity_mut(&mut self) -> &mut Activity { &mut self.inner } } impl AsQuestion for Question { fn question_ref(&self) -> &Question { self } fn question_mut(&mut self) -> &mut Question { self } } impl AsActivity for ApObject where Inner: AsActivity, { fn activity_ref(&self) -> &Activity { self.inner.activity_ref() } fn activity_mut(&mut self) -> &mut Activity { self.inner.activity_mut() } } impl ActorAndObjectRef for ApObject where Inner: ActorAndObjectRef, { fn actor_field_ref(&self) -> &OneOrMany { self.inner.actor_field_ref() } fn object_field_ref(&self) -> &OneOrMany { self.inner.object_field_ref() } fn actor_field_mut(&mut self) -> &mut OneOrMany { self.inner.actor_field_mut() } fn object_field_mut(&mut self) -> &mut OneOrMany { self.inner.object_field_mut() } } impl TargetRef for ApObject where Inner: TargetRef, { fn target_field_ref(&self) -> &OneOrMany { self.inner.target_field_ref() } fn target_field_mut(&mut self) -> &mut OneOrMany { self.inner.target_field_mut() } } impl OriginRef for ApObject where Inner: OriginRef, { fn origin_field_ref(&self) -> &OneOrMany { self.inner.origin_field_ref() } fn origin_field_mut(&mut self) -> &mut OneOrMany { self.inner.origin_field_mut() } } impl OptTargetRef for ApObject where Inner: OptTargetRef, { fn target_field_ref(&self) -> &Option> { self.inner.target_field_ref() } fn target_field_mut(&mut self) -> &mut Option> { self.inner.target_field_mut() } } impl OptOriginRef for ApObject where Inner: OptOriginRef, { fn origin_field_ref(&self) -> &Option> { self.inner.origin_field_ref() } fn origin_field_mut(&mut self) -> &mut Option> { self.inner.origin_field_mut() } } impl AsQuestion for ApObject where Inner: AsQuestion, { fn question_ref(&self) -> &Question { self.inner.question_ref() } fn question_mut(&mut self) -> &mut Question { self.inner.question_mut() } } impl ActivityExt for T where T: AsActivity {} impl ActorAndObjectRefExt for T where T: ActorAndObjectRef {} impl TargetRefExt for T where T: TargetRef {} impl OriginRefExt for T where T: OriginRef {} impl OptTargetRefExt for T where T: OptTargetRef {} impl OptOriginRefExt for T where T: OptOriginRef {} impl QuestionExt for T where T: AsQuestion {}