mirror of
https://git.asonix.dog/asonix/activitystreams.git
synced 2024-11-22 03:40:59 +00:00
Refactor Kind out of trait signatures
This commit is contained in:
parent
3887886785
commit
a0fef3abc4
18 changed files with 2454 additions and 1934 deletions
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "activitystreams"
|
name = "activitystreams"
|
||||||
description = "A set of core types and traits for activitystreams data"
|
description = "A set of core types and traits for activitystreams data"
|
||||||
version = "0.7.0-alpha.20"
|
version = "0.7.0-alpha.21"
|
||||||
license = "GPL-3.0"
|
license = "GPL-3.0"
|
||||||
authors = ["asonix <asonix@asonix.dog>"]
|
authors = ["asonix <asonix@asonix.dog>"]
|
||||||
repository = "https://git.asonix.dog/asonix/activitystreams"
|
repository = "https://git.asonix.dog/asonix/activitystreams"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "activitystreams-ext"
|
name = "activitystreams-ext"
|
||||||
description = "Extension types for the ActivityStreams crate"
|
description = "Extension types for the ActivityStreams crate"
|
||||||
version = "0.1.0-alpha.2"
|
version = "0.1.0-alpha.3"
|
||||||
license = "GPL-3.0"
|
license = "GPL-3.0"
|
||||||
authors = ["asonix <asonix@asonix.dog>"]
|
authors = ["asonix <asonix@asonix.dog>"]
|
||||||
repository = "https://git.asonix.dog/Aardwolf/activitystreams"
|
repository = "https://git.asonix.dog/Aardwolf/activitystreams"
|
||||||
|
@ -13,7 +13,7 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
activitystreams = { version = "0.7.0-alpha.3", path = ".." }
|
activitystreams = { version = "0.7.0-alpha.21", path = ".." }
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use activitystreams::{
|
use activitystreams::{
|
||||||
actor::{ApActor, Person},
|
actor::{ApActor, Person},
|
||||||
context,
|
context,
|
||||||
|
iri_string::types::IriString,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
security,
|
security,
|
||||||
unparsed::UnparsedMutExt,
|
unparsed::UnparsedMutExt,
|
||||||
url::Url,
|
|
||||||
};
|
};
|
||||||
use activitystreams_ext::{Ext1, UnparsedExtension};
|
use activitystreams_ext::{Ext1, UnparsedExtension};
|
||||||
|
|
||||||
|
@ -17,8 +17,8 @@ pub struct PublicKey {
|
||||||
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
|
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct PublicKeyInner {
|
pub struct PublicKeyInner {
|
||||||
id: Url,
|
id: IriString,
|
||||||
owner: Url,
|
owner: IriString,
|
||||||
public_key_pem: String,
|
public_key_pem: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
use crate::Ext1;
|
use crate::Ext1;
|
||||||
use activitystreams::{
|
use activitystreams::{
|
||||||
activity::{
|
activity::{
|
||||||
Activity, ActorAndObjectRef, AsActivity, AsQuestion, OptOriginRef, OptTargetRef, OriginRef,
|
Activity, ActivityActor, ActivityObject, AsActivity, AsActivityActor, AsActivityObject,
|
||||||
Question, TargetRef,
|
AsOptOrigin, AsOptTarget, AsOrigin, AsQuestion, AsTarget, OptOrigin, OptTarget, Origin,
|
||||||
|
Question, Target,
|
||||||
},
|
},
|
||||||
actor::{ApActor, AsApActor},
|
actor::{ApActor, AsApActor},
|
||||||
base::{AnyBase, AsBase, Base},
|
base::{AsBase, Base},
|
||||||
collection::{AsCollection, AsCollectionPage, Collection, CollectionPage},
|
collection::{AsCollection, AsCollectionPage, Collection, CollectionPage},
|
||||||
markers,
|
markers,
|
||||||
object::{ApObject, AsApObject, AsObject, Object},
|
object::{ApObject, AsApObject, AsObject, Object},
|
||||||
primitives::OneOrMany,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
impl<Inner, A> markers::Base for Ext1<Inner, A> where Inner: markers::Base {}
|
impl<Inner, A> markers::Base for Ext1<Inner, A> where Inner: markers::Base {}
|
||||||
|
@ -23,28 +23,32 @@ impl<Inner, A> markers::IntransitiveActivity for Ext1<Inner, A> where
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, Kind> AsBase<Kind> for Ext1<Inner, A>
|
impl<Inner, A> AsBase for Ext1<Inner, A>
|
||||||
where
|
where
|
||||||
Inner: AsBase<Kind>,
|
Inner: AsBase,
|
||||||
{
|
{
|
||||||
fn base_ref(&self) -> &Base<Kind> {
|
type Kind = Inner::Kind;
|
||||||
|
|
||||||
|
fn base_ref(&self) -> &Base<Self::Kind> {
|
||||||
self.inner.base_ref()
|
self.inner.base_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn base_mut(&mut self) -> &mut Base<Kind> {
|
fn base_mut(&mut self) -> &mut Base<Self::Kind> {
|
||||||
self.inner.base_mut()
|
self.inner.base_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, Kind> AsObject<Kind> for Ext1<Inner, A>
|
impl<Inner, A> AsObject for Ext1<Inner, A>
|
||||||
where
|
where
|
||||||
Inner: AsObject<Kind>,
|
Inner: AsObject,
|
||||||
{
|
{
|
||||||
fn object_ref(&self) -> &Object<Kind> {
|
type Kind = Inner::Kind;
|
||||||
|
|
||||||
|
fn object_ref(&self) -> &Object<Self::Kind> {
|
||||||
self.inner.object_ref()
|
self.inner.object_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn object_mut(&mut self) -> &mut Object<Kind> {
|
fn object_mut(&mut self) -> &mut Object<Self::Kind> {
|
||||||
self.inner.object_mut()
|
self.inner.object_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,28 +66,32 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, Kind> AsCollection<Kind> for Ext1<Inner, A>
|
impl<Inner, A> AsCollection for Ext1<Inner, A>
|
||||||
where
|
where
|
||||||
Inner: AsCollection<Kind>,
|
Inner: AsCollection,
|
||||||
{
|
{
|
||||||
fn collection_ref(&self) -> &Collection<Kind> {
|
type Kind = Inner::Kind;
|
||||||
|
|
||||||
|
fn collection_ref(&self) -> &Collection<Self::Kind> {
|
||||||
self.inner.collection_ref()
|
self.inner.collection_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collection_mut(&mut self) -> &mut Collection<Kind> {
|
fn collection_mut(&mut self) -> &mut Collection<Self::Kind> {
|
||||||
self.inner.collection_mut()
|
self.inner.collection_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, Kind> AsCollectionPage<Kind> for Ext1<Inner, A>
|
impl<Inner, A> AsCollectionPage for Ext1<Inner, A>
|
||||||
where
|
where
|
||||||
Inner: AsCollectionPage<Kind>,
|
Inner: AsCollectionPage,
|
||||||
{
|
{
|
||||||
fn collection_page_ref(&self) -> &CollectionPage<Kind> {
|
type Kind = Inner::Kind;
|
||||||
|
|
||||||
|
fn collection_page_ref(&self) -> &CollectionPage<Self::Kind> {
|
||||||
self.inner.collection_page_ref()
|
self.inner.collection_page_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collection_page_mut(&mut self) -> &mut CollectionPage<Kind> {
|
fn collection_page_mut(&mut self) -> &mut CollectionPage<Self::Kind> {
|
||||||
self.inner.collection_page_mut()
|
self.inner.collection_page_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,89 +109,108 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, Kind> AsActivity<Kind> for Ext1<Inner, A>
|
impl<Inner, A> AsActivity for Ext1<Inner, A>
|
||||||
where
|
where
|
||||||
Inner: AsActivity<Kind>,
|
Inner: AsActivity,
|
||||||
{
|
{
|
||||||
fn activity_ref(&self) -> &Activity<Kind> {
|
type Kind = Inner::Kind;
|
||||||
|
|
||||||
|
fn activity_ref(&self) -> &Activity<Self::Kind> {
|
||||||
self.inner.activity_ref()
|
self.inner.activity_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn activity_mut(&mut self) -> &mut Activity<Kind> {
|
fn activity_mut(&mut self) -> &mut Activity<Self::Kind> {
|
||||||
self.inner.activity_mut()
|
self.inner.activity_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A> ActorAndObjectRef for Ext1<Inner, A>
|
impl<Inner, A> AsActivityActor for Ext1<Inner, A>
|
||||||
where
|
where
|
||||||
Inner: ActorAndObjectRef,
|
Inner: AsActivityActor,
|
||||||
{
|
{
|
||||||
fn actor_field_ref(&self) -> &OneOrMany<AnyBase> {
|
type Inner = Inner::Inner;
|
||||||
self.inner.actor_field_ref()
|
|
||||||
|
fn activity_actor_ref(&self) -> &ActivityActor<Self::Inner> {
|
||||||
|
self.inner.activity_actor_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn actor_field_mut(&mut self) -> &mut OneOrMany<AnyBase> {
|
fn activity_actor_mut(&mut self) -> &mut ActivityActor<Self::Inner> {
|
||||||
self.inner.actor_field_mut()
|
self.inner.activity_actor_mut()
|
||||||
}
|
|
||||||
|
|
||||||
fn object_field_ref(&self) -> &OneOrMany<AnyBase> {
|
|
||||||
self.inner.object_field_ref()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn object_field_mut(&mut self) -> &mut OneOrMany<AnyBase> {
|
|
||||||
self.inner.object_field_mut()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A> TargetRef for Ext1<Inner, A>
|
impl<Inner, A> AsActivityObject for Ext1<Inner, A>
|
||||||
where
|
where
|
||||||
Inner: TargetRef,
|
Inner: AsActivityObject,
|
||||||
{
|
{
|
||||||
fn target_field_ref(&self) -> &OneOrMany<AnyBase> {
|
type Inner = Inner::Inner;
|
||||||
self.inner.target_field_ref()
|
|
||||||
|
fn activity_object_ref(&self) -> &ActivityObject<Self::Inner> {
|
||||||
|
self.inner.activity_object_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn target_field_mut(&mut self) -> &mut OneOrMany<AnyBase> {
|
fn activity_object_mut(&mut self) -> &mut ActivityObject<Self::Inner> {
|
||||||
self.inner.target_field_mut()
|
self.inner.activity_object_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A> OriginRef for Ext1<Inner, A>
|
impl<Inner, A> AsTarget for Ext1<Inner, A>
|
||||||
where
|
where
|
||||||
Inner: OriginRef,
|
Inner: AsTarget,
|
||||||
{
|
{
|
||||||
fn origin_field_ref(&self) -> &OneOrMany<AnyBase> {
|
type Inner = Inner::Inner;
|
||||||
self.inner.origin_field_ref()
|
|
||||||
|
fn target_ref(&self) -> &Target<Self::Inner> {
|
||||||
|
self.inner.target_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn origin_field_mut(&mut self) -> &mut OneOrMany<AnyBase> {
|
fn target_mut(&mut self) -> &mut Target<Self::Inner> {
|
||||||
self.inner.origin_field_mut()
|
self.inner.target_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A> OptTargetRef for Ext1<Inner, A>
|
impl<Inner, A> AsOrigin for Ext1<Inner, A>
|
||||||
where
|
where
|
||||||
Inner: OptTargetRef,
|
Inner: AsOrigin,
|
||||||
{
|
{
|
||||||
fn target_field_ref(&self) -> &Option<OneOrMany<AnyBase>> {
|
type Inner = Inner::Inner;
|
||||||
self.inner.target_field_ref()
|
|
||||||
|
fn origin_ref(&self) -> &Origin<Self::Inner> {
|
||||||
|
self.inner.origin_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn target_field_mut(&mut self) -> &mut Option<OneOrMany<AnyBase>> {
|
fn origin_mut(&mut self) -> &mut Origin<Self::Inner> {
|
||||||
self.inner.target_field_mut()
|
self.inner.origin_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A> OptOriginRef for Ext1<Inner, A>
|
impl<Inner, A> AsOptTarget for Ext1<Inner, A>
|
||||||
where
|
where
|
||||||
Inner: OptOriginRef,
|
Inner: AsOptTarget,
|
||||||
{
|
{
|
||||||
fn origin_field_ref(&self) -> &Option<OneOrMany<AnyBase>> {
|
type Inner = Inner::Inner;
|
||||||
self.inner.origin_field_ref()
|
|
||||||
|
fn opt_target_ref(&self) -> &OptTarget<Self::Inner> {
|
||||||
|
self.inner.opt_target_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn origin_field_mut(&mut self) -> &mut Option<OneOrMany<AnyBase>> {
|
fn opt_target_mut(&mut self) -> &mut OptTarget<Self::Inner> {
|
||||||
self.inner.origin_field_mut()
|
self.inner.opt_target_mut()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<Inner, A> AsOptOrigin for Ext1<Inner, A>
|
||||||
|
where
|
||||||
|
Inner: AsOptOrigin,
|
||||||
|
{
|
||||||
|
type Inner = Inner::Inner;
|
||||||
|
|
||||||
|
fn opt_origin_ref(&self) -> &OptOrigin<Self::Inner> {
|
||||||
|
self.inner.opt_origin_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn opt_origin_mut(&mut self) -> &mut OptOrigin<Self::Inner> {
|
||||||
|
self.inner.opt_origin_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
use crate::Ext2;
|
use crate::Ext2;
|
||||||
use activitystreams::{
|
use activitystreams::{
|
||||||
activity::{
|
activity::{
|
||||||
Activity, ActorAndObjectRef, AsActivity, AsQuestion, OptOriginRef, OptTargetRef, OriginRef,
|
Activity, ActivityActor, ActivityObject, AsActivity, AsActivityActor, AsActivityObject,
|
||||||
Question, TargetRef,
|
AsOptOrigin, AsOptTarget, AsOrigin, AsQuestion, AsTarget, OptOrigin, OptTarget, Origin,
|
||||||
|
Question, Target,
|
||||||
},
|
},
|
||||||
actor::{ApActor, AsApActor},
|
actor::{ApActor, AsApActor},
|
||||||
base::{AnyBase, AsBase, Base},
|
base::{AsBase, Base},
|
||||||
collection::{AsCollection, AsCollectionPage, Collection, CollectionPage},
|
collection::{AsCollection, AsCollectionPage, Collection, CollectionPage},
|
||||||
markers,
|
markers,
|
||||||
object::{ApObject, AsApObject, AsObject, Object},
|
object::{ApObject, AsApObject, AsObject, Object},
|
||||||
primitives::OneOrMany,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
impl<Inner, A, B> markers::Base for Ext2<Inner, A, B> where Inner: markers::Base {}
|
impl<Inner, A, B> markers::Base for Ext2<Inner, A, B> where Inner: markers::Base {}
|
||||||
|
@ -23,28 +23,32 @@ impl<Inner, A, B> markers::IntransitiveActivity for Ext2<Inner, A, B> where
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B, Kind> AsBase<Kind> for Ext2<Inner, A, B>
|
impl<Inner, A, B> AsBase for Ext2<Inner, A, B>
|
||||||
where
|
where
|
||||||
Inner: AsBase<Kind>,
|
Inner: AsBase,
|
||||||
{
|
{
|
||||||
fn base_ref(&self) -> &Base<Kind> {
|
type Kind = Inner::Kind;
|
||||||
|
|
||||||
|
fn base_ref(&self) -> &Base<Self::Kind> {
|
||||||
self.inner.base_ref()
|
self.inner.base_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn base_mut(&mut self) -> &mut Base<Kind> {
|
fn base_mut(&mut self) -> &mut Base<Self::Kind> {
|
||||||
self.inner.base_mut()
|
self.inner.base_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B, Kind> AsObject<Kind> for Ext2<Inner, A, B>
|
impl<Inner, A, B> AsObject for Ext2<Inner, A, B>
|
||||||
where
|
where
|
||||||
Inner: AsObject<Kind>,
|
Inner: AsObject,
|
||||||
{
|
{
|
||||||
fn object_ref(&self) -> &Object<Kind> {
|
type Kind = Inner::Kind;
|
||||||
|
|
||||||
|
fn object_ref(&self) -> &Object<Self::Kind> {
|
||||||
self.inner.object_ref()
|
self.inner.object_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn object_mut(&mut self) -> &mut Object<Kind> {
|
fn object_mut(&mut self) -> &mut Object<Self::Kind> {
|
||||||
self.inner.object_mut()
|
self.inner.object_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,28 +66,32 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B, Kind> AsCollection<Kind> for Ext2<Inner, A, B>
|
impl<Inner, A, B> AsCollection for Ext2<Inner, A, B>
|
||||||
where
|
where
|
||||||
Inner: AsCollection<Kind>,
|
Inner: AsCollection,
|
||||||
{
|
{
|
||||||
fn collection_ref(&self) -> &Collection<Kind> {
|
type Kind = Inner::Kind;
|
||||||
|
|
||||||
|
fn collection_ref(&self) -> &Collection<Self::Kind> {
|
||||||
self.inner.collection_ref()
|
self.inner.collection_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collection_mut(&mut self) -> &mut Collection<Kind> {
|
fn collection_mut(&mut self) -> &mut Collection<Self::Kind> {
|
||||||
self.inner.collection_mut()
|
self.inner.collection_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B, Kind> AsCollectionPage<Kind> for Ext2<Inner, A, B>
|
impl<Inner, A, B> AsCollectionPage for Ext2<Inner, A, B>
|
||||||
where
|
where
|
||||||
Inner: AsCollectionPage<Kind>,
|
Inner: AsCollectionPage,
|
||||||
{
|
{
|
||||||
fn collection_page_ref(&self) -> &CollectionPage<Kind> {
|
type Kind = Inner::Kind;
|
||||||
|
|
||||||
|
fn collection_page_ref(&self) -> &CollectionPage<Self::Kind> {
|
||||||
self.inner.collection_page_ref()
|
self.inner.collection_page_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collection_page_mut(&mut self) -> &mut CollectionPage<Kind> {
|
fn collection_page_mut(&mut self) -> &mut CollectionPage<Self::Kind> {
|
||||||
self.inner.collection_page_mut()
|
self.inner.collection_page_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,89 +109,108 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B, Kind> AsActivity<Kind> for Ext2<Inner, A, B>
|
impl<Inner, A, B> AsActivity for Ext2<Inner, A, B>
|
||||||
where
|
where
|
||||||
Inner: AsActivity<Kind>,
|
Inner: AsActivity,
|
||||||
{
|
{
|
||||||
fn activity_ref(&self) -> &Activity<Kind> {
|
type Kind = Inner::Kind;
|
||||||
|
|
||||||
|
fn activity_ref(&self) -> &Activity<Self::Kind> {
|
||||||
self.inner.activity_ref()
|
self.inner.activity_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn activity_mut(&mut self) -> &mut Activity<Kind> {
|
fn activity_mut(&mut self) -> &mut Activity<Self::Kind> {
|
||||||
self.inner.activity_mut()
|
self.inner.activity_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B> ActorAndObjectRef for Ext2<Inner, A, B>
|
impl<Inner, A, B> AsActivityActor for Ext2<Inner, A, B>
|
||||||
where
|
where
|
||||||
Inner: ActorAndObjectRef,
|
Inner: AsActivityActor,
|
||||||
{
|
{
|
||||||
fn actor_field_ref(&self) -> &OneOrMany<AnyBase> {
|
type Inner = Inner::Inner;
|
||||||
self.inner.actor_field_ref()
|
|
||||||
|
fn activity_actor_ref(&self) -> &ActivityActor<Self::Inner> {
|
||||||
|
self.inner.activity_actor_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn actor_field_mut(&mut self) -> &mut OneOrMany<AnyBase> {
|
fn activity_actor_mut(&mut self) -> &mut ActivityActor<Self::Inner> {
|
||||||
self.inner.actor_field_mut()
|
self.inner.activity_actor_mut()
|
||||||
}
|
|
||||||
|
|
||||||
fn object_field_ref(&self) -> &OneOrMany<AnyBase> {
|
|
||||||
self.inner.object_field_ref()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn object_field_mut(&mut self) -> &mut OneOrMany<AnyBase> {
|
|
||||||
self.inner.object_field_mut()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B> TargetRef for Ext2<Inner, A, B>
|
impl<Inner, A, B> AsActivityObject for Ext2<Inner, A, B>
|
||||||
where
|
where
|
||||||
Inner: TargetRef,
|
Inner: AsActivityObject,
|
||||||
{
|
{
|
||||||
fn target_field_ref(&self) -> &OneOrMany<AnyBase> {
|
type Inner = Inner::Inner;
|
||||||
self.inner.target_field_ref()
|
|
||||||
|
fn activity_object_ref(&self) -> &ActivityObject<Self::Inner> {
|
||||||
|
self.inner.activity_object_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn target_field_mut(&mut self) -> &mut OneOrMany<AnyBase> {
|
fn activity_object_mut(&mut self) -> &mut ActivityObject<Self::Inner> {
|
||||||
self.inner.target_field_mut()
|
self.inner.activity_object_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B> OriginRef for Ext2<Inner, A, B>
|
impl<Inner, A, B> AsTarget for Ext2<Inner, A, B>
|
||||||
where
|
where
|
||||||
Inner: OriginRef,
|
Inner: AsTarget,
|
||||||
{
|
{
|
||||||
fn origin_field_ref(&self) -> &OneOrMany<AnyBase> {
|
type Inner = Inner::Inner;
|
||||||
self.inner.origin_field_ref()
|
|
||||||
|
fn target_ref(&self) -> &Target<Self::Inner> {
|
||||||
|
self.inner.target_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn origin_field_mut(&mut self) -> &mut OneOrMany<AnyBase> {
|
fn target_mut(&mut self) -> &mut Target<Self::Inner> {
|
||||||
self.inner.origin_field_mut()
|
self.inner.target_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B> OptTargetRef for Ext2<Inner, A, B>
|
impl<Inner, A, B> AsOrigin for Ext2<Inner, A, B>
|
||||||
where
|
where
|
||||||
Inner: OptTargetRef,
|
Inner: AsOrigin,
|
||||||
{
|
{
|
||||||
fn target_field_ref(&self) -> &Option<OneOrMany<AnyBase>> {
|
type Inner = Inner::Inner;
|
||||||
self.inner.target_field_ref()
|
|
||||||
|
fn origin_ref(&self) -> &Origin<Self::Inner> {
|
||||||
|
self.inner.origin_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn target_field_mut(&mut self) -> &mut Option<OneOrMany<AnyBase>> {
|
fn origin_mut(&mut self) -> &mut Origin<Self::Inner> {
|
||||||
self.inner.target_field_mut()
|
self.inner.origin_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B> OptOriginRef for Ext2<Inner, A, B>
|
impl<Inner, A, B> AsOptTarget for Ext2<Inner, A, B>
|
||||||
where
|
where
|
||||||
Inner: OptOriginRef,
|
Inner: AsOptTarget,
|
||||||
{
|
{
|
||||||
fn origin_field_ref(&self) -> &Option<OneOrMany<AnyBase>> {
|
type Inner = Inner::Inner;
|
||||||
self.inner.origin_field_ref()
|
|
||||||
|
fn opt_target_ref(&self) -> &OptTarget<Self::Inner> {
|
||||||
|
self.inner.opt_target_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn origin_field_mut(&mut self) -> &mut Option<OneOrMany<AnyBase>> {
|
fn opt_target_mut(&mut self) -> &mut OptTarget<Self::Inner> {
|
||||||
self.inner.origin_field_mut()
|
self.inner.opt_target_mut()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<Inner, A, B> AsOptOrigin for Ext2<Inner, A, B>
|
||||||
|
where
|
||||||
|
Inner: AsOptOrigin,
|
||||||
|
{
|
||||||
|
type Inner = Inner::Inner;
|
||||||
|
|
||||||
|
fn opt_origin_ref(&self) -> &OptOrigin<Self::Inner> {
|
||||||
|
self.inner.opt_origin_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn opt_origin_mut(&mut self) -> &mut OptOrigin<Self::Inner> {
|
||||||
|
self.inner.opt_origin_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
use crate::Ext3;
|
use crate::Ext3;
|
||||||
use activitystreams::{
|
use activitystreams::{
|
||||||
activity::{
|
activity::{
|
||||||
Activity, ActorAndObjectRef, AsActivity, AsQuestion, OptOriginRef, OptTargetRef, OriginRef,
|
Activity, ActivityActor, ActivityObject, AsActivity, AsActivityActor, AsActivityObject,
|
||||||
Question, TargetRef,
|
AsOptOrigin, AsOptTarget, AsOrigin, AsQuestion, AsTarget, OptOrigin, OptTarget, Origin,
|
||||||
|
Question, Target,
|
||||||
},
|
},
|
||||||
actor::{ApActor, AsApActor},
|
actor::{ApActor, AsApActor},
|
||||||
base::{AnyBase, AsBase, Base},
|
base::{AsBase, Base},
|
||||||
collection::{AsCollection, AsCollectionPage, Collection, CollectionPage},
|
collection::{AsCollection, AsCollectionPage, Collection, CollectionPage},
|
||||||
markers,
|
markers,
|
||||||
object::{ApObject, AsApObject, AsObject, Object},
|
object::{ApObject, AsApObject, AsObject, Object},
|
||||||
primitives::OneOrMany,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
impl<Inner, A, B, C> markers::Base for Ext3<Inner, A, B, C> where Inner: markers::Base {}
|
impl<Inner, A, B, C> markers::Base for Ext3<Inner, A, B, C> where Inner: markers::Base {}
|
||||||
|
@ -26,28 +26,32 @@ impl<Inner, A, B, C> markers::IntransitiveActivity for Ext3<Inner, A, B, C> wher
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B, C, Kind> AsBase<Kind> for Ext3<Inner, A, B, C>
|
impl<Inner, A, B, C> AsBase for Ext3<Inner, A, B, C>
|
||||||
where
|
where
|
||||||
Inner: AsBase<Kind>,
|
Inner: AsBase,
|
||||||
{
|
{
|
||||||
fn base_ref(&self) -> &Base<Kind> {
|
type Kind = Inner::Kind;
|
||||||
|
|
||||||
|
fn base_ref(&self) -> &Base<Self::Kind> {
|
||||||
self.inner.base_ref()
|
self.inner.base_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn base_mut(&mut self) -> &mut Base<Kind> {
|
fn base_mut(&mut self) -> &mut Base<Self::Kind> {
|
||||||
self.inner.base_mut()
|
self.inner.base_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B, C, Kind> AsObject<Kind> for Ext3<Inner, A, B, C>
|
impl<Inner, A, B, C> AsObject for Ext3<Inner, A, B, C>
|
||||||
where
|
where
|
||||||
Inner: AsObject<Kind>,
|
Inner: AsObject,
|
||||||
{
|
{
|
||||||
fn object_ref(&self) -> &Object<Kind> {
|
type Kind = Inner::Kind;
|
||||||
|
|
||||||
|
fn object_ref(&self) -> &Object<Self::Kind> {
|
||||||
self.inner.object_ref()
|
self.inner.object_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn object_mut(&mut self) -> &mut Object<Kind> {
|
fn object_mut(&mut self) -> &mut Object<Self::Kind> {
|
||||||
self.inner.object_mut()
|
self.inner.object_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,28 +69,32 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B, C, Kind> AsCollection<Kind> for Ext3<Inner, A, B, C>
|
impl<Inner, A, B, C> AsCollection for Ext3<Inner, A, B, C>
|
||||||
where
|
where
|
||||||
Inner: AsCollection<Kind>,
|
Inner: AsCollection,
|
||||||
{
|
{
|
||||||
fn collection_ref(&self) -> &Collection<Kind> {
|
type Kind = Inner::Kind;
|
||||||
|
|
||||||
|
fn collection_ref(&self) -> &Collection<Self::Kind> {
|
||||||
self.inner.collection_ref()
|
self.inner.collection_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collection_mut(&mut self) -> &mut Collection<Kind> {
|
fn collection_mut(&mut self) -> &mut Collection<Self::Kind> {
|
||||||
self.inner.collection_mut()
|
self.inner.collection_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B, C, Kind> AsCollectionPage<Kind> for Ext3<Inner, A, B, C>
|
impl<Inner, A, B, C> AsCollectionPage for Ext3<Inner, A, B, C>
|
||||||
where
|
where
|
||||||
Inner: AsCollectionPage<Kind>,
|
Inner: AsCollectionPage,
|
||||||
{
|
{
|
||||||
fn collection_page_ref(&self) -> &CollectionPage<Kind> {
|
type Kind = Inner::Kind;
|
||||||
|
|
||||||
|
fn collection_page_ref(&self) -> &CollectionPage<Self::Kind> {
|
||||||
self.inner.collection_page_ref()
|
self.inner.collection_page_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collection_page_mut(&mut self) -> &mut CollectionPage<Kind> {
|
fn collection_page_mut(&mut self) -> &mut CollectionPage<Self::Kind> {
|
||||||
self.inner.collection_page_mut()
|
self.inner.collection_page_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,89 +112,108 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B, C, Kind> AsActivity<Kind> for Ext3<Inner, A, B, C>
|
impl<Inner, A, B, C> AsActivity for Ext3<Inner, A, B, C>
|
||||||
where
|
where
|
||||||
Inner: AsActivity<Kind>,
|
Inner: AsActivity,
|
||||||
{
|
{
|
||||||
fn activity_ref(&self) -> &Activity<Kind> {
|
type Kind = Inner::Kind;
|
||||||
|
|
||||||
|
fn activity_ref(&self) -> &Activity<Self::Kind> {
|
||||||
self.inner.activity_ref()
|
self.inner.activity_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn activity_mut(&mut self) -> &mut Activity<Kind> {
|
fn activity_mut(&mut self) -> &mut Activity<Self::Kind> {
|
||||||
self.inner.activity_mut()
|
self.inner.activity_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B, C> ActorAndObjectRef for Ext3<Inner, A, B, C>
|
impl<Inner, A, B, C> AsActivityActor for Ext3<Inner, A, B, C>
|
||||||
where
|
where
|
||||||
Inner: ActorAndObjectRef,
|
Inner: AsActivityActor,
|
||||||
{
|
{
|
||||||
fn actor_field_ref(&self) -> &OneOrMany<AnyBase> {
|
type Inner = Inner::Inner;
|
||||||
self.inner.actor_field_ref()
|
|
||||||
|
fn activity_actor_ref(&self) -> &ActivityActor<Self::Inner> {
|
||||||
|
self.inner.activity_actor_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn actor_field_mut(&mut self) -> &mut OneOrMany<AnyBase> {
|
fn activity_actor_mut(&mut self) -> &mut ActivityActor<Self::Inner> {
|
||||||
self.inner.actor_field_mut()
|
self.inner.activity_actor_mut()
|
||||||
}
|
|
||||||
|
|
||||||
fn object_field_ref(&self) -> &OneOrMany<AnyBase> {
|
|
||||||
self.inner.object_field_ref()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn object_field_mut(&mut self) -> &mut OneOrMany<AnyBase> {
|
|
||||||
self.inner.object_field_mut()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B, C> TargetRef for Ext3<Inner, A, B, C>
|
impl<Inner, A, B, C> AsActivityObject for Ext3<Inner, A, B, C>
|
||||||
where
|
where
|
||||||
Inner: TargetRef,
|
Inner: AsActivityObject,
|
||||||
{
|
{
|
||||||
fn target_field_ref(&self) -> &OneOrMany<AnyBase> {
|
type Inner = Inner::Inner;
|
||||||
self.inner.target_field_ref()
|
|
||||||
|
fn activity_object_ref(&self) -> &ActivityObject<Self::Inner> {
|
||||||
|
self.inner.activity_object_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn target_field_mut(&mut self) -> &mut OneOrMany<AnyBase> {
|
fn activity_object_mut(&mut self) -> &mut ActivityObject<Self::Inner> {
|
||||||
self.inner.target_field_mut()
|
self.inner.activity_object_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B, C> OriginRef for Ext3<Inner, A, B, C>
|
impl<Inner, A, B, C> AsTarget for Ext3<Inner, A, B, C>
|
||||||
where
|
where
|
||||||
Inner: OriginRef,
|
Inner: AsTarget,
|
||||||
{
|
{
|
||||||
fn origin_field_ref(&self) -> &OneOrMany<AnyBase> {
|
type Inner = Inner::Inner;
|
||||||
self.inner.origin_field_ref()
|
|
||||||
|
fn target_ref(&self) -> &Target<Self::Inner> {
|
||||||
|
self.inner.target_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn origin_field_mut(&mut self) -> &mut OneOrMany<AnyBase> {
|
fn target_mut(&mut self) -> &mut Target<Self::Inner> {
|
||||||
self.inner.origin_field_mut()
|
self.inner.target_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B, C> OptTargetRef for Ext3<Inner, A, B, C>
|
impl<Inner, A, B, C> AsOrigin for Ext3<Inner, A, B, C>
|
||||||
where
|
where
|
||||||
Inner: OptTargetRef,
|
Inner: AsOrigin,
|
||||||
{
|
{
|
||||||
fn target_field_ref(&self) -> &Option<OneOrMany<AnyBase>> {
|
type Inner = Inner::Inner;
|
||||||
self.inner.target_field_ref()
|
|
||||||
|
fn origin_ref(&self) -> &Origin<Self::Inner> {
|
||||||
|
self.inner.origin_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn target_field_mut(&mut self) -> &mut Option<OneOrMany<AnyBase>> {
|
fn origin_mut(&mut self) -> &mut Origin<Self::Inner> {
|
||||||
self.inner.target_field_mut()
|
self.inner.origin_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B, C> OptOriginRef for Ext3<Inner, A, B, C>
|
impl<Inner, A, B, C> AsOptTarget for Ext3<Inner, A, B, C>
|
||||||
where
|
where
|
||||||
Inner: OptOriginRef,
|
Inner: AsOptTarget,
|
||||||
{
|
{
|
||||||
fn origin_field_ref(&self) -> &Option<OneOrMany<AnyBase>> {
|
type Inner = Inner::Inner;
|
||||||
self.inner.origin_field_ref()
|
|
||||||
|
fn opt_target_ref(&self) -> &OptTarget<Self::Inner> {
|
||||||
|
self.inner.opt_target_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn origin_field_mut(&mut self) -> &mut Option<OneOrMany<AnyBase>> {
|
fn opt_target_mut(&mut self) -> &mut OptTarget<Self::Inner> {
|
||||||
self.inner.origin_field_mut()
|
self.inner.opt_target_mut()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<Inner, A, B, C> AsOptOrigin for Ext3<Inner, A, B, C>
|
||||||
|
where
|
||||||
|
Inner: AsOptOrigin,
|
||||||
|
{
|
||||||
|
type Inner = Inner::Inner;
|
||||||
|
|
||||||
|
fn opt_origin_ref(&self) -> &OptOrigin<Self::Inner> {
|
||||||
|
self.inner.opt_origin_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn opt_origin_mut(&mut self) -> &mut OptOrigin<Self::Inner> {
|
||||||
|
self.inner.opt_origin_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
use crate::Ext4;
|
use crate::Ext4;
|
||||||
use activitystreams::{
|
use activitystreams::{
|
||||||
activity::{
|
activity::{
|
||||||
Activity, ActorAndObjectRef, AsActivity, AsQuestion, OptOriginRef, OptTargetRef, OriginRef,
|
Activity, ActivityActor, ActivityObject, AsActivity, AsActivityActor, AsActivityObject,
|
||||||
Question, TargetRef,
|
AsOptOrigin, AsOptTarget, AsOrigin, AsQuestion, AsTarget, OptOrigin, OptTarget, Origin,
|
||||||
|
Question, Target,
|
||||||
},
|
},
|
||||||
actor::{ApActor, AsApActor},
|
actor::{ApActor, AsApActor},
|
||||||
base::{AnyBase, AsBase, Base},
|
base::{AsBase, Base},
|
||||||
collection::{AsCollection, AsCollectionPage, Collection, CollectionPage},
|
collection::{AsCollection, AsCollectionPage, Collection, CollectionPage},
|
||||||
markers,
|
markers,
|
||||||
object::{ApObject, AsApObject, AsObject, Object},
|
object::{ApObject, AsApObject, AsObject, Object},
|
||||||
primitives::OneOrMany,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
impl<Inner, A, B, C, D> markers::Base for Ext4<Inner, A, B, C, D> where Inner: markers::Base {}
|
impl<Inner, A, B, C, D> markers::Base for Ext4<Inner, A, B, C, D> where Inner: markers::Base {}
|
||||||
|
@ -29,28 +29,32 @@ impl<Inner, A, B, C, D> markers::IntransitiveActivity for Ext4<Inner, A, B, C, D
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B, C, D, Kind> AsBase<Kind> for Ext4<Inner, A, B, C, D>
|
impl<Inner, A, B, C, D> AsBase for Ext4<Inner, A, B, C, D>
|
||||||
where
|
where
|
||||||
Inner: AsBase<Kind>,
|
Inner: AsBase,
|
||||||
{
|
{
|
||||||
fn base_ref(&self) -> &Base<Kind> {
|
type Kind = Inner::Kind;
|
||||||
|
|
||||||
|
fn base_ref(&self) -> &Base<Self::Kind> {
|
||||||
self.inner.base_ref()
|
self.inner.base_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn base_mut(&mut self) -> &mut Base<Kind> {
|
fn base_mut(&mut self) -> &mut Base<Self::Kind> {
|
||||||
self.inner.base_mut()
|
self.inner.base_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B, C, D, Kind> AsObject<Kind> for Ext4<Inner, A, B, C, D>
|
impl<Inner, A, B, C, D> AsObject for Ext4<Inner, A, B, C, D>
|
||||||
where
|
where
|
||||||
Inner: AsObject<Kind>,
|
Inner: AsObject,
|
||||||
{
|
{
|
||||||
fn object_ref(&self) -> &Object<Kind> {
|
type Kind = Inner::Kind;
|
||||||
|
|
||||||
|
fn object_ref(&self) -> &Object<Self::Kind> {
|
||||||
self.inner.object_ref()
|
self.inner.object_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn object_mut(&mut self) -> &mut Object<Kind> {
|
fn object_mut(&mut self) -> &mut Object<Self::Kind> {
|
||||||
self.inner.object_mut()
|
self.inner.object_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,28 +72,32 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B, C, D, Kind> AsCollection<Kind> for Ext4<Inner, A, B, C, D>
|
impl<Inner, A, B, C, D> AsCollection for Ext4<Inner, A, B, C, D>
|
||||||
where
|
where
|
||||||
Inner: AsCollection<Kind>,
|
Inner: AsCollection,
|
||||||
{
|
{
|
||||||
fn collection_ref(&self) -> &Collection<Kind> {
|
type Kind = Inner::Kind;
|
||||||
|
|
||||||
|
fn collection_ref(&self) -> &Collection<Self::Kind> {
|
||||||
self.inner.collection_ref()
|
self.inner.collection_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collection_mut(&mut self) -> &mut Collection<Kind> {
|
fn collection_mut(&mut self) -> &mut Collection<Self::Kind> {
|
||||||
self.inner.collection_mut()
|
self.inner.collection_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B, C, D, Kind> AsCollectionPage<Kind> for Ext4<Inner, A, B, C, D>
|
impl<Inner, A, B, C, D> AsCollectionPage for Ext4<Inner, A, B, C, D>
|
||||||
where
|
where
|
||||||
Inner: AsCollectionPage<Kind>,
|
Inner: AsCollectionPage,
|
||||||
{
|
{
|
||||||
fn collection_page_ref(&self) -> &CollectionPage<Kind> {
|
type Kind = Inner::Kind;
|
||||||
|
|
||||||
|
fn collection_page_ref(&self) -> &CollectionPage<Self::Kind> {
|
||||||
self.inner.collection_page_ref()
|
self.inner.collection_page_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collection_page_mut(&mut self) -> &mut CollectionPage<Kind> {
|
fn collection_page_mut(&mut self) -> &mut CollectionPage<Self::Kind> {
|
||||||
self.inner.collection_page_mut()
|
self.inner.collection_page_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,89 +115,108 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B, C, D, Kind> AsActivity<Kind> for Ext4<Inner, A, B, C, D>
|
impl<Inner, A, B, C, D> AsActivity for Ext4<Inner, A, B, C, D>
|
||||||
where
|
where
|
||||||
Inner: AsActivity<Kind>,
|
Inner: AsActivity,
|
||||||
{
|
{
|
||||||
fn activity_ref(&self) -> &Activity<Kind> {
|
type Kind = Inner::Kind;
|
||||||
|
|
||||||
|
fn activity_ref(&self) -> &Activity<Self::Kind> {
|
||||||
self.inner.activity_ref()
|
self.inner.activity_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn activity_mut(&mut self) -> &mut Activity<Kind> {
|
fn activity_mut(&mut self) -> &mut Activity<Self::Kind> {
|
||||||
self.inner.activity_mut()
|
self.inner.activity_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B, C, D> ActorAndObjectRef for Ext4<Inner, A, B, C, D>
|
impl<Inner, A, B, C, D> AsActivityActor for Ext4<Inner, A, B, C, D>
|
||||||
where
|
where
|
||||||
Inner: ActorAndObjectRef,
|
Inner: AsActivityActor,
|
||||||
{
|
{
|
||||||
fn actor_field_ref(&self) -> &OneOrMany<AnyBase> {
|
type Inner = Inner::Inner;
|
||||||
self.inner.actor_field_ref()
|
|
||||||
|
fn activity_actor_ref(&self) -> &ActivityActor<Self::Inner> {
|
||||||
|
self.inner.activity_actor_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn actor_field_mut(&mut self) -> &mut OneOrMany<AnyBase> {
|
fn activity_actor_mut(&mut self) -> &mut ActivityActor<Self::Inner> {
|
||||||
self.inner.actor_field_mut()
|
self.inner.activity_actor_mut()
|
||||||
}
|
|
||||||
|
|
||||||
fn object_field_ref(&self) -> &OneOrMany<AnyBase> {
|
|
||||||
self.inner.object_field_ref()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn object_field_mut(&mut self) -> &mut OneOrMany<AnyBase> {
|
|
||||||
self.inner.object_field_mut()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B, C, D> TargetRef for Ext4<Inner, A, B, C, D>
|
impl<Inner, A, B, C, D> AsActivityObject for Ext4<Inner, A, B, C, D>
|
||||||
where
|
where
|
||||||
Inner: TargetRef,
|
Inner: AsActivityObject,
|
||||||
{
|
{
|
||||||
fn target_field_ref(&self) -> &OneOrMany<AnyBase> {
|
type Inner = Inner::Inner;
|
||||||
self.inner.target_field_ref()
|
|
||||||
|
fn activity_object_ref(&self) -> &ActivityObject<Self::Inner> {
|
||||||
|
self.inner.activity_object_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn target_field_mut(&mut self) -> &mut OneOrMany<AnyBase> {
|
fn activity_object_mut(&mut self) -> &mut ActivityObject<Self::Inner> {
|
||||||
self.inner.target_field_mut()
|
self.inner.activity_object_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B, C, D> OriginRef for Ext4<Inner, A, B, C, D>
|
impl<Inner, A, B, C, D> AsTarget for Ext4<Inner, A, B, C, D>
|
||||||
where
|
where
|
||||||
Inner: OriginRef,
|
Inner: AsTarget,
|
||||||
{
|
{
|
||||||
fn origin_field_ref(&self) -> &OneOrMany<AnyBase> {
|
type Inner = Inner::Inner;
|
||||||
self.inner.origin_field_ref()
|
|
||||||
|
fn target_ref(&self) -> &Target<Self::Inner> {
|
||||||
|
self.inner.target_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn origin_field_mut(&mut self) -> &mut OneOrMany<AnyBase> {
|
fn target_mut(&mut self) -> &mut Target<Self::Inner> {
|
||||||
self.inner.origin_field_mut()
|
self.inner.target_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B, C, D> OptTargetRef for Ext4<Inner, A, B, C, D>
|
impl<Inner, A, B, C, D> AsOrigin for Ext4<Inner, A, B, C, D>
|
||||||
where
|
where
|
||||||
Inner: OptTargetRef,
|
Inner: AsOrigin,
|
||||||
{
|
{
|
||||||
fn target_field_ref(&self) -> &Option<OneOrMany<AnyBase>> {
|
type Inner = Inner::Inner;
|
||||||
self.inner.target_field_ref()
|
|
||||||
|
fn origin_ref(&self) -> &Origin<Self::Inner> {
|
||||||
|
self.inner.origin_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn target_field_mut(&mut self) -> &mut Option<OneOrMany<AnyBase>> {
|
fn origin_mut(&mut self) -> &mut Origin<Self::Inner> {
|
||||||
self.inner.target_field_mut()
|
self.inner.origin_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B, C, D> OptOriginRef for Ext4<Inner, A, B, C, D>
|
impl<Inner, A, B, C, D> AsOptTarget for Ext4<Inner, A, B, C, D>
|
||||||
where
|
where
|
||||||
Inner: OptOriginRef,
|
Inner: AsOptTarget,
|
||||||
{
|
{
|
||||||
fn origin_field_ref(&self) -> &Option<OneOrMany<AnyBase>> {
|
type Inner = Inner::Inner;
|
||||||
self.inner.origin_field_ref()
|
|
||||||
|
fn opt_target_ref(&self) -> &OptTarget<Self::Inner> {
|
||||||
|
self.inner.opt_target_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn origin_field_mut(&mut self) -> &mut Option<OneOrMany<AnyBase>> {
|
fn opt_target_mut(&mut self) -> &mut OptTarget<Self::Inner> {
|
||||||
self.inner.origin_field_mut()
|
self.inner.opt_target_mut()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<Inner, A, B, C, D> AsOptOrigin for Ext4<Inner, A, B, C, D>
|
||||||
|
where
|
||||||
|
Inner: AsOptOrigin,
|
||||||
|
{
|
||||||
|
type Inner = Inner::Inner;
|
||||||
|
|
||||||
|
fn opt_origin_ref(&self) -> &OptOrigin<Self::Inner> {
|
||||||
|
self.inner.opt_origin_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn opt_origin_mut(&mut self) -> &mut OptOrigin<Self::Inner> {
|
||||||
|
self.inner.opt_origin_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
//! # An extension API for activitystreams
|
//! # An extension API for activitystreams
|
||||||
//! _This crate provides Ext1, Ext2, Ext3, and Ext4 for adding extensions to ActivityStreams types_
|
//! _This crate provides Ext1, Ext2, Ext3, and Ext4 for adding extensions to ActivityStreams types_
|
||||||
//!
|
//!
|
||||||
//! - Find the code on [git.asonix.dog](https://git.asonix.dog/Aardwolf/activitystreams)
|
//! - Find the code on [git.asonix.dog](https://git.asonix.dog/asonix/activitystreams)
|
||||||
//! - Read the docs on [docs.rs](https://docs.rs/activitystreams-ext)
|
//! - Read the docs on [docs.rs](https://docs.rs/activitystreams-ext)
|
||||||
//! - Join the matrix channel at [#activitypub:asonix.dog](https://matrix.to/#/!fAEcHyTUdAaKCzIKCt:asonix.dog?via=asonix.dog&via=matrix.org&via=t2bot.io)
|
//! - Join the matrix channel at [#activitypub:asonix.dog](https://matrix.to/#/!fAEcHyTUdAaKCzIKCt:asonix.dog?via=asonix.dog&via=matrix.org&via=t2bot.io)
|
||||||
//! - Hit me up on [mastodon](https://asonix.dog/@asonix)
|
//! - Hit me up on [mastodon](https://masto.asonix.dog/@asonix)
|
||||||
//!
|
//!
|
||||||
//! ## Usage
|
//! ## Usage
|
||||||
//!
|
//!
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
//! prelude::*,
|
//! prelude::*,
|
||||||
//! security,
|
//! security,
|
||||||
//! unparsed::UnparsedMutExt,
|
//! unparsed::UnparsedMutExt,
|
||||||
//! url::Url,
|
//! iri_string::types::IriString,
|
||||||
//! };
|
//! };
|
||||||
//! use activitystreams_ext::{Ext1, UnparsedExtension};
|
//! use activitystreams_ext::{Ext1, UnparsedExtension};
|
||||||
//!
|
//!
|
||||||
|
@ -36,8 +36,8 @@
|
||||||
//! #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
|
//! #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
|
||||||
//! #[serde(rename_all = "camelCase")]
|
//! #[serde(rename_all = "camelCase")]
|
||||||
//! pub struct PublicKeyInner {
|
//! pub struct PublicKeyInner {
|
||||||
//! id: Url,
|
//! id: IriString,
|
||||||
//! owner: Url,
|
//! owner: IriString,
|
||||||
//! public_key_pem: String,
|
//! public_key_pem: String,
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
|
@ -264,22 +264,24 @@ impl<Inner, A, B, C, D> Ext4<Inner, A, B, C, D> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, Kind, Error> Extends<Kind> for Ext1<Inner, A>
|
impl<Inner, A, Error> Extends for Ext1<Inner, A>
|
||||||
where
|
where
|
||||||
Inner: Extends<Kind, Error = Error> + UnparsedMut,
|
Inner: Extends<Error = Error> + UnparsedMut,
|
||||||
A: UnparsedExtension<Inner, Error = Error>,
|
A: UnparsedExtension<Inner, Error = Error>,
|
||||||
Error: From<serde_json::Error> + std::error::Error,
|
Error: From<serde_json::Error> + std::error::Error,
|
||||||
{
|
{
|
||||||
|
type Kind = Inner::Kind;
|
||||||
|
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
fn extends(base: Base<Kind>) -> Result<Self, Self::Error> {
|
fn extends(base: Base<Self::Kind>) -> Result<Self, Self::Error> {
|
||||||
let mut inner = Inner::extends(base)?;
|
let mut inner = Inner::extends(base)?;
|
||||||
let ext_one = A::try_from_unparsed(&mut inner)?;
|
let ext_one = A::try_from_unparsed(&mut inner)?;
|
||||||
|
|
||||||
Ok(Ext1 { inner, ext_one })
|
Ok(Ext1 { inner, ext_one })
|
||||||
}
|
}
|
||||||
|
|
||||||
fn retracts(self) -> Result<Base<Kind>, Self::Error> {
|
fn retracts(self) -> Result<Base<Self::Kind>, Self::Error> {
|
||||||
let Ext1 { mut inner, ext_one } = self;
|
let Ext1 { mut inner, ext_one } = self;
|
||||||
|
|
||||||
ext_one.try_into_unparsed(&mut inner)?;
|
ext_one.try_into_unparsed(&mut inner)?;
|
||||||
|
@ -287,16 +289,18 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B, Kind, Error> Extends<Kind> for Ext2<Inner, A, B>
|
impl<Inner, A, B, Error> Extends for Ext2<Inner, A, B>
|
||||||
where
|
where
|
||||||
Inner: Extends<Kind, Error = Error> + UnparsedMut,
|
Inner: Extends<Error = Error> + UnparsedMut,
|
||||||
A: UnparsedExtension<Inner, Error = Error>,
|
A: UnparsedExtension<Inner, Error = Error>,
|
||||||
B: UnparsedExtension<Inner, Error = Error>,
|
B: UnparsedExtension<Inner, Error = Error>,
|
||||||
Error: From<serde_json::Error> + std::error::Error,
|
Error: From<serde_json::Error> + std::error::Error,
|
||||||
{
|
{
|
||||||
|
type Kind = Inner::Kind;
|
||||||
|
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
fn extends(base: Base<Kind>) -> Result<Self, Self::Error> {
|
fn extends(base: Base<Self::Kind>) -> Result<Self, Self::Error> {
|
||||||
let mut inner = Inner::extends(base)?;
|
let mut inner = Inner::extends(base)?;
|
||||||
let ext_one = A::try_from_unparsed(&mut inner)?;
|
let ext_one = A::try_from_unparsed(&mut inner)?;
|
||||||
let ext_two = B::try_from_unparsed(&mut inner)?;
|
let ext_two = B::try_from_unparsed(&mut inner)?;
|
||||||
|
@ -308,7 +312,7 @@ where
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn retracts(self) -> Result<Base<Kind>, Self::Error> {
|
fn retracts(self) -> Result<Base<Self::Kind>, Self::Error> {
|
||||||
let Ext2 {
|
let Ext2 {
|
||||||
mut inner,
|
mut inner,
|
||||||
ext_one,
|
ext_one,
|
||||||
|
@ -321,17 +325,19 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B, C, Kind, Error> Extends<Kind> for Ext3<Inner, A, B, C>
|
impl<Inner, A, B, C, Error> Extends for Ext3<Inner, A, B, C>
|
||||||
where
|
where
|
||||||
Inner: Extends<Kind, Error = Error> + UnparsedMut,
|
Inner: Extends<Error = Error> + UnparsedMut,
|
||||||
A: UnparsedExtension<Inner, Error = Error>,
|
A: UnparsedExtension<Inner, Error = Error>,
|
||||||
B: UnparsedExtension<Inner, Error = Error>,
|
B: UnparsedExtension<Inner, Error = Error>,
|
||||||
C: UnparsedExtension<Inner, Error = Error>,
|
C: UnparsedExtension<Inner, Error = Error>,
|
||||||
Error: From<serde_json::Error> + std::error::Error,
|
Error: From<serde_json::Error> + std::error::Error,
|
||||||
{
|
{
|
||||||
|
type Kind = Inner::Kind;
|
||||||
|
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
fn extends(base: Base<Kind>) -> Result<Self, Self::Error> {
|
fn extends(base: Base<Self::Kind>) -> Result<Self, Self::Error> {
|
||||||
let mut inner = Inner::extends(base)?;
|
let mut inner = Inner::extends(base)?;
|
||||||
let ext_one = A::try_from_unparsed(&mut inner)?;
|
let ext_one = A::try_from_unparsed(&mut inner)?;
|
||||||
let ext_two = B::try_from_unparsed(&mut inner)?;
|
let ext_two = B::try_from_unparsed(&mut inner)?;
|
||||||
|
@ -345,7 +351,7 @@ where
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn retracts(self) -> Result<Base<Kind>, Self::Error> {
|
fn retracts(self) -> Result<Base<Self::Kind>, Self::Error> {
|
||||||
let Ext3 {
|
let Ext3 {
|
||||||
mut inner,
|
mut inner,
|
||||||
ext_one,
|
ext_one,
|
||||||
|
@ -360,18 +366,20 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, A, B, C, D, Kind, Error> Extends<Kind> for Ext4<Inner, A, B, C, D>
|
impl<Inner, A, B, C, D, Error> Extends for Ext4<Inner, A, B, C, D>
|
||||||
where
|
where
|
||||||
Inner: Extends<Kind, Error = Error> + UnparsedMut,
|
Inner: Extends<Error = Error> + UnparsedMut,
|
||||||
A: UnparsedExtension<Inner, Error = Error>,
|
A: UnparsedExtension<Inner, Error = Error>,
|
||||||
B: UnparsedExtension<Inner, Error = Error>,
|
B: UnparsedExtension<Inner, Error = Error>,
|
||||||
C: UnparsedExtension<Inner, Error = Error>,
|
C: UnparsedExtension<Inner, Error = Error>,
|
||||||
D: UnparsedExtension<Inner, Error = Error>,
|
D: UnparsedExtension<Inner, Error = Error>,
|
||||||
Error: From<serde_json::Error> + std::error::Error,
|
Error: From<serde_json::Error> + std::error::Error,
|
||||||
{
|
{
|
||||||
|
type Kind = Inner::Kind;
|
||||||
|
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
fn extends(base: Base<Kind>) -> Result<Self, Self::Error> {
|
fn extends(base: Base<Self::Kind>) -> Result<Self, Self::Error> {
|
||||||
let mut inner = Inner::extends(base)?;
|
let mut inner = Inner::extends(base)?;
|
||||||
let ext_one = A::try_from_unparsed(&mut inner)?;
|
let ext_one = A::try_from_unparsed(&mut inner)?;
|
||||||
let ext_two = B::try_from_unparsed(&mut inner)?;
|
let ext_two = B::try_from_unparsed(&mut inner)?;
|
||||||
|
@ -387,7 +395,7 @@ where
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn retracts(self) -> Result<Base<Kind>, Self::Error> {
|
fn retracts(self) -> Result<Base<Self::Kind>, Self::Error> {
|
||||||
let Ext4 {
|
let Ext4 {
|
||||||
mut inner,
|
mut inner,
|
||||||
ext_one,
|
ext_one,
|
||||||
|
|
|
@ -33,7 +33,7 @@ pub fn handle_activity(activity: AcceptedActivity) -> Result<(), anyhow::Error>
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
static EXAMPLE_JSON: &str = r#"{"actor":"https://asonix.dog/users/asonix","object":"https://asonix.dog/users/asonix/posts/1","type":"Announce"}"#;
|
static EXAMPLE_JSON: &str = r#"{"id":"https://asonix.dog/activities/1","actor":"https://asonix.dog/users/asonix","object":"https://asonix.dog/users/asonix/posts/1","type":"Announce"}"#;
|
||||||
|
|
||||||
fn main() -> Result<(), anyhow::Error> {
|
fn main() -> Result<(), anyhow::Error> {
|
||||||
handle_activity(serde_json::from_str(EXAMPLE_JSON)?)
|
handle_activity(serde_json::from_str(EXAMPLE_JSON)?)
|
||||||
|
|
3139
src/activity.rs
3139
src/activity.rs
File diff suppressed because it is too large
Load diff
82
src/actor.rs
82
src/actor.rs
|
@ -62,10 +62,10 @@ pub trait ApActorExt<Inner>: AsApActor<Inner> {
|
||||||
///
|
///
|
||||||
/// let inbox_ref = person.inbox();
|
/// let inbox_ref = person.inbox();
|
||||||
/// ```
|
/// ```
|
||||||
fn inbox<'a, Kind>(&'a self) -> Result<&'a IriString, CheckError>
|
fn inbox<'a>(&'a self) -> Result<&'a IriString, CheckError>
|
||||||
where
|
where
|
||||||
Inner: 'a,
|
Inner: 'a,
|
||||||
Self: BaseExt<Kind>,
|
Self: BaseExt,
|
||||||
{
|
{
|
||||||
let inbox = self.inbox_unchecked();
|
let inbox = self.inbox_unchecked();
|
||||||
self.check_authority(inbox)
|
self.check_authority(inbox)
|
||||||
|
@ -129,10 +129,10 @@ pub trait ApActorExt<Inner>: AsApActor<Inner> {
|
||||||
///
|
///
|
||||||
/// let outbox_ref = person.outbox();
|
/// let outbox_ref = person.outbox();
|
||||||
/// ```
|
/// ```
|
||||||
fn outbox<'a, Kind>(&'a self) -> Result<Option<&'a IriString>, CheckError>
|
fn outbox<'a>(&'a self) -> Result<Option<&'a IriString>, CheckError>
|
||||||
where
|
where
|
||||||
Inner: 'a,
|
Inner: 'a,
|
||||||
Self: BaseExt<Kind>,
|
Self: BaseExt,
|
||||||
{
|
{
|
||||||
self.outbox_unchecked()
|
self.outbox_unchecked()
|
||||||
.map(|outbox| self.check_authority(outbox))
|
.map(|outbox| self.check_authority(outbox))
|
||||||
|
@ -236,10 +236,10 @@ pub trait ApActorExt<Inner>: AsApActor<Inner> {
|
||||||
/// println!("{:?}", following);
|
/// println!("{:?}", following);
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
fn following<'a, Kind>(&'a self) -> Result<Option<&'a IriString>, CheckError>
|
fn following<'a>(&'a self) -> Result<Option<&'a IriString>, CheckError>
|
||||||
where
|
where
|
||||||
Inner: 'a,
|
Inner: 'a,
|
||||||
Self: BaseExt<Kind>,
|
Self: BaseExt,
|
||||||
{
|
{
|
||||||
self.following_unchecked()
|
self.following_unchecked()
|
||||||
.map(|following| self.check_authority(following))
|
.map(|following| self.check_authority(following))
|
||||||
|
@ -345,10 +345,10 @@ pub trait ApActorExt<Inner>: AsApActor<Inner> {
|
||||||
/// println!("{:?}", followers);
|
/// println!("{:?}", followers);
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
fn followers<'a, Kind>(&'a self) -> Result<Option<&'a IriString>, CheckError>
|
fn followers<'a>(&'a self) -> Result<Option<&'a IriString>, CheckError>
|
||||||
where
|
where
|
||||||
Inner: 'a,
|
Inner: 'a,
|
||||||
Self: BaseExt<Kind>,
|
Self: BaseExt,
|
||||||
{
|
{
|
||||||
self.followers_unchecked()
|
self.followers_unchecked()
|
||||||
.map(|followers| self.check_authority(followers))
|
.map(|followers| self.check_authority(followers))
|
||||||
|
@ -454,10 +454,10 @@ pub trait ApActorExt<Inner>: AsApActor<Inner> {
|
||||||
/// println!("{:?}", liked);
|
/// println!("{:?}", liked);
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
fn liked<'a, Kind>(&'a self) -> Result<Option<&'a IriString>, CheckError>
|
fn liked<'a>(&'a self) -> Result<Option<&'a IriString>, CheckError>
|
||||||
where
|
where
|
||||||
Inner: 'a,
|
Inner: 'a,
|
||||||
Self: BaseExt<Kind>,
|
Self: BaseExt,
|
||||||
{
|
{
|
||||||
self.liked_unchecked()
|
self.liked_unchecked()
|
||||||
.map(|liked| self.check_authority(liked))
|
.map(|liked| self.check_authority(liked))
|
||||||
|
@ -563,10 +563,10 @@ pub trait ApActorExt<Inner>: AsApActor<Inner> {
|
||||||
/// println!("{:?}", streams);
|
/// println!("{:?}", streams);
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
fn streams<'a, Kind>(&'a self) -> Result<Option<OneOrMany<&'a IriString>>, CheckError>
|
fn streams<'a>(&'a self) -> Result<Option<OneOrMany<&'a IriString>>, CheckError>
|
||||||
where
|
where
|
||||||
Inner: 'a,
|
Inner: 'a,
|
||||||
Self: BaseExt<Kind>,
|
Self: BaseExt,
|
||||||
{
|
{
|
||||||
if let Some(streams) = self.streams_unchecked() {
|
if let Some(streams) = self.streams_unchecked() {
|
||||||
for id in &streams {
|
for id in &streams {
|
||||||
|
@ -810,11 +810,10 @@ pub trait ApActorExt<Inner>: AsApActor<Inner> {
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
fn endpoints<'a, Kind>(&'a self) -> Result<Option<Endpoints<&'a IriString>>, CheckError>
|
fn endpoints<'a>(&'a self) -> Result<Option<Endpoints<&'a IriString>>, CheckError>
|
||||||
where
|
where
|
||||||
Self: BaseExt<Kind>,
|
Self: BaseExt,
|
||||||
Inner: 'a,
|
Inner: 'a,
|
||||||
Kind: 'a,
|
|
||||||
{
|
{
|
||||||
if let Some(endpoints) = self.endpoints_unchecked() {
|
if let Some(endpoints) = self.endpoints_unchecked() {
|
||||||
let authority_opt = self.id_unchecked().and_then(|id| id.authority_components());
|
let authority_opt = self.id_unchecked().and_then(|id| id.authority_components());
|
||||||
|
@ -1416,19 +1415,20 @@ impl<Inner> markers::Actor for ApActor<Inner> where Inner: markers::Actor {}
|
||||||
|
|
||||||
impl<Inner> markers::Actor for ApObject<Inner> where Inner: markers::Actor {}
|
impl<Inner> markers::Actor for ApObject<Inner> where Inner: markers::Actor {}
|
||||||
|
|
||||||
impl<Inner, Kind, Error> Extends<Kind> for ApActor<Inner>
|
impl<Inner, Error> Extends for ApActor<Inner>
|
||||||
where
|
where
|
||||||
Inner: Extends<Kind, Error = Error> + UnparsedMut + markers::Actor,
|
Inner: Extends<Error = Error> + UnparsedMut + markers::Actor,
|
||||||
Error: From<serde_json::Error> + std::error::Error,
|
Error: From<serde_json::Error> + std::error::Error,
|
||||||
{
|
{
|
||||||
|
type Kind = Inner::Kind;
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
fn extends(base: Base<Kind>) -> Result<Self, Self::Error> {
|
fn extends(base: Base<Self::Kind>) -> Result<Self, Self::Error> {
|
||||||
let inner = Inner::extends(base)?;
|
let inner = Inner::extends(base)?;
|
||||||
Ok(Self::extending(inner)?)
|
Ok(Self::extending(inner)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn retracts(self) -> Result<Base<Kind>, Self::Error> {
|
fn retracts(self) -> Result<Base<Self::Kind>, Self::Error> {
|
||||||
let inner = self.retracting()?;
|
let inner = self.retracting()?;
|
||||||
inner.retracts()
|
inner.retracts()
|
||||||
}
|
}
|
||||||
|
@ -1443,28 +1443,32 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, Kind> AsBase<Kind> for ApActor<Inner>
|
impl<Inner> AsBase for ApActor<Inner>
|
||||||
where
|
where
|
||||||
Inner: AsBase<Kind>,
|
Inner: AsBase,
|
||||||
{
|
{
|
||||||
fn base_ref(&self) -> &Base<Kind> {
|
type Kind = Inner::Kind;
|
||||||
|
|
||||||
|
fn base_ref(&self) -> &Base<Self::Kind> {
|
||||||
self.inner.base_ref()
|
self.inner.base_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn base_mut(&mut self) -> &mut Base<Kind> {
|
fn base_mut(&mut self) -> &mut Base<Self::Kind> {
|
||||||
self.inner.base_mut()
|
self.inner.base_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, Kind> AsObject<Kind> for ApActor<Inner>
|
impl<Inner> AsObject for ApActor<Inner>
|
||||||
where
|
where
|
||||||
Inner: AsObject<Kind>,
|
Inner: AsObject,
|
||||||
{
|
{
|
||||||
fn object_ref(&self) -> &Object<Kind> {
|
type Kind = Inner::Kind;
|
||||||
|
|
||||||
|
fn object_ref(&self) -> &Object<Self::Kind> {
|
||||||
self.inner.object_ref()
|
self.inner.object_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn object_mut(&mut self) -> &mut Object<Kind> {
|
fn object_mut(&mut self) -> &mut Object<Self::Kind> {
|
||||||
self.inner.object_mut()
|
self.inner.object_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1495,14 +1499,16 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Kind> Extends<Kind> for Actor<Kind> {
|
impl<Kind> Extends for Actor<Kind> {
|
||||||
|
type Kind = Kind;
|
||||||
|
|
||||||
type Error = serde_json::Error;
|
type Error = serde_json::Error;
|
||||||
|
|
||||||
fn extends(base: Base<Kind>) -> Result<Self, Self::Error> {
|
fn extends(base: Base<Self::Kind>) -> Result<Self, Self::Error> {
|
||||||
Object::extends(base).map(Actor)
|
Object::extends(base).map(Actor)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn retracts(self) -> Result<Base<Kind>, Self::Error> {
|
fn retracts(self) -> Result<Base<Self::Kind>, Self::Error> {
|
||||||
self.0.retracts()
|
self.0.retracts()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1513,22 +1519,26 @@ impl<Kind> UnparsedMut for Actor<Kind> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Kind> AsBase<Kind> for Actor<Kind> {
|
impl<Kind> AsBase for Actor<Kind> {
|
||||||
fn base_ref(&self) -> &Base<Kind> {
|
type Kind = Kind;
|
||||||
|
|
||||||
|
fn base_ref(&self) -> &Base<Self::Kind> {
|
||||||
self.0.base_ref()
|
self.0.base_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn base_mut(&mut self) -> &mut Base<Kind> {
|
fn base_mut(&mut self) -> &mut Base<Self::Kind> {
|
||||||
self.0.base_mut()
|
self.0.base_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Kind> AsObject<Kind> for Actor<Kind> {
|
impl<Kind> AsObject for Actor<Kind> {
|
||||||
fn object_ref(&self) -> &Object<Kind> {
|
type Kind = Kind;
|
||||||
|
|
||||||
|
fn object_ref(&self) -> &Object<Self::Kind> {
|
||||||
self.0.object_ref()
|
self.0.object_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn object_mut(&mut self) -> &mut Object<Kind> {
|
fn object_mut(&mut self) -> &mut Object<Self::Kind> {
|
||||||
self.0.object_mut()
|
self.0.object_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
85
src/base.rs
85
src/base.rs
|
@ -38,22 +38,24 @@ use mime::Mime;
|
||||||
|
|
||||||
/// Implements conversion between `Base<Kind>` and other ActivityStreams objects defined in this
|
/// Implements conversion between `Base<Kind>` and other ActivityStreams objects defined in this
|
||||||
/// crate
|
/// crate
|
||||||
pub trait Extends<Kind>: Sized {
|
pub trait Extends: Sized {
|
||||||
|
type Kind;
|
||||||
|
|
||||||
/// The erro produced must be a StdError
|
/// The erro produced must be a StdError
|
||||||
type Error: std::error::Error;
|
type Error: std::error::Error;
|
||||||
|
|
||||||
/// Produce an object from the Base
|
/// Produce an object from the Base
|
||||||
fn extends(base: Base<Kind>) -> Result<Self, Self::Error>;
|
fn extends(base: Base<Self::Kind>) -> Result<Self, Self::Error>;
|
||||||
|
|
||||||
/// Produce a base from the object
|
/// Produce a base from the object
|
||||||
fn retracts(self) -> Result<Base<Kind>, Self::Error>;
|
fn retracts(self) -> Result<Base<Self::Kind>, Self::Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A helper function implemented for all Extends types to easily produce an AnyBase from a given
|
/// A helper function implemented for all Extends types to easily produce an AnyBase from a given
|
||||||
/// object.
|
/// object.
|
||||||
///
|
///
|
||||||
/// This is important because many APIs in this crate deal with AnyBases.
|
/// This is important because many APIs in this crate deal with AnyBases.
|
||||||
pub trait ExtendsExt<Kind>: Extends<Kind> {
|
pub trait ExtendsExt: Extends {
|
||||||
/// Create an AnyBase from the given object
|
/// Create an AnyBase from the given object
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
|
@ -68,7 +70,7 @@ pub trait ExtendsExt<Kind>: Extends<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn into_any_base(self) -> Result<AnyBase, Self::Error>
|
fn into_any_base(self) -> Result<AnyBase, Self::Error>
|
||||||
where
|
where
|
||||||
Kind: serde::ser::Serialize,
|
Self::Kind: serde::ser::Serialize,
|
||||||
Self::Error: From<serde_json::Error>,
|
Self::Error: From<serde_json::Error>,
|
||||||
{
|
{
|
||||||
AnyBase::from_extended(self)
|
AnyBase::from_extended(self)
|
||||||
|
@ -91,7 +93,7 @@ pub trait ExtendsExt<Kind>: Extends<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn from_any_base(any_base: AnyBase) -> Result<Option<Self>, Self::Error>
|
fn from_any_base(any_base: AnyBase) -> Result<Option<Self>, Self::Error>
|
||||||
where
|
where
|
||||||
Kind: serde::de::DeserializeOwned,
|
Self::Kind: serde::de::DeserializeOwned,
|
||||||
Self::Error: From<serde_json::Error>,
|
Self::Error: From<serde_json::Error>,
|
||||||
{
|
{
|
||||||
if let Some(base) = any_base.take_base() {
|
if let Some(base) = any_base.take_base() {
|
||||||
|
@ -108,12 +110,14 @@ pub trait ExtendsExt<Kind>: Extends<Kind> {
|
||||||
/// Implementation trait for deriving Base methods for a type
|
/// Implementation trait for deriving Base methods for a type
|
||||||
///
|
///
|
||||||
/// Any type implementating AsBase will automatically gain methods provided by BaseExt
|
/// Any type implementating AsBase will automatically gain methods provided by BaseExt
|
||||||
pub trait AsBase<Kind>: markers::Base {
|
pub trait AsBase: markers::Base {
|
||||||
|
type Kind;
|
||||||
|
|
||||||
/// Immutable borrow of `Base<Kind>`
|
/// Immutable borrow of `Base<Kind>`
|
||||||
fn base_ref(&self) -> &Base<Kind>;
|
fn base_ref(&self) -> &Base<Self::Kind>;
|
||||||
|
|
||||||
/// Mutable borrow of Base<Kind>
|
/// Mutable borrow of Base<Kind>
|
||||||
fn base_mut(&mut self) -> &mut Base<Kind>;
|
fn base_mut(&mut self) -> &mut Base<Self::Kind>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper methods for interacting with Base types
|
/// Helper methods for interacting with Base types
|
||||||
|
@ -122,7 +126,7 @@ pub trait AsBase<Kind>: markers::Base {
|
||||||
/// Link or an Object.
|
/// Link or an Object.
|
||||||
///
|
///
|
||||||
/// Documentation for the fields related to these methods can be found on the `Base` struct
|
/// Documentation for the fields related to these methods can be found on the `Base` struct
|
||||||
pub trait BaseExt<Kind>: AsBase<Kind> {
|
pub trait BaseExt: AsBase {
|
||||||
/// Fetch the context for the current object
|
/// Fetch the context for the current object
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
|
@ -135,7 +139,7 @@ pub trait BaseExt<Kind>: AsBase<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn context<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
fn context<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.base_ref().context.as_ref()
|
self.base_ref().context.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -277,7 +281,7 @@ pub trait BaseExt<Kind>: AsBase<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn id<'a>(&'a self, host: &str, port: Option<&str>) -> Result<Option<&'a IriString>, CheckError>
|
fn id<'a>(&'a self, host: &str, port: Option<&str>) -> Result<Option<&'a IriString>, CheckError>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.id_unchecked()
|
self.id_unchecked()
|
||||||
.and_then(|id| {
|
.and_then(|id| {
|
||||||
|
@ -306,7 +310,7 @@ pub trait BaseExt<Kind>: AsBase<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn id_unchecked<'a>(&'a self) -> Option<&'a IriString>
|
fn id_unchecked<'a>(&'a self) -> Option<&'a IriString>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.base_ref().id.as_ref()
|
self.base_ref().id.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -329,7 +333,7 @@ pub trait BaseExt<Kind>: AsBase<Kind> {
|
||||||
port: Option<&str>,
|
port: Option<&str>,
|
||||||
) -> Result<Option<&'a mut IriString>, CheckError>
|
) -> Result<Option<&'a mut IriString>, CheckError>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.id_mut_unchecked()
|
self.id_mut_unchecked()
|
||||||
.and_then(|id| {
|
.and_then(|id| {
|
||||||
|
@ -358,7 +362,7 @@ pub trait BaseExt<Kind>: AsBase<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn id_mut_unchecked<'a>(&'a mut self) -> Option<&'a mut IriString>
|
fn id_mut_unchecked<'a>(&'a mut self) -> Option<&'a mut IriString>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.base_mut().id.as_mut()
|
self.base_mut().id.as_mut()
|
||||||
}
|
}
|
||||||
|
@ -445,9 +449,9 @@ pub trait BaseExt<Kind>: AsBase<Kind> {
|
||||||
/// println!("{:?}", kind);
|
/// println!("{:?}", kind);
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
fn kind<'a>(&'a self) -> Option<&'a Kind>
|
fn kind<'a>(&'a self) -> Option<&'a Self::Kind>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.base_ref().kind.as_ref()
|
self.base_ref().kind.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -470,9 +474,9 @@ pub trait BaseExt<Kind>: AsBase<Kind> {
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
fn is_kind(&self, kind: &Kind) -> bool
|
fn is_kind(&self, kind: &Self::Kind) -> bool
|
||||||
where
|
where
|
||||||
Kind: PartialEq,
|
Self::Kind: PartialEq,
|
||||||
{
|
{
|
||||||
self.kind() == Some(kind)
|
self.kind() == Some(kind)
|
||||||
}
|
}
|
||||||
|
@ -488,7 +492,7 @@ pub trait BaseExt<Kind>: AsBase<Kind> {
|
||||||
///
|
///
|
||||||
/// video.set_kind(VideoType::Video);
|
/// video.set_kind(VideoType::Video);
|
||||||
/// ```
|
/// ```
|
||||||
fn set_kind(&mut self, kind: Kind) -> &mut Self {
|
fn set_kind(&mut self, kind: Self::Kind) -> &mut Self {
|
||||||
self.base_mut().kind = Some(kind);
|
self.base_mut().kind = Some(kind);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -505,7 +509,7 @@ pub trait BaseExt<Kind>: AsBase<Kind> {
|
||||||
/// println!("{:?}", kind);
|
/// println!("{:?}", kind);
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
fn take_kind(&mut self) -> Option<Kind> {
|
fn take_kind(&mut self) -> Option<Self::Kind> {
|
||||||
self.base_mut().kind.take()
|
self.base_mut().kind.take()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -541,7 +545,7 @@ pub trait BaseExt<Kind>: AsBase<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn name<'a>(&'a self) -> Option<OneOrMany<&'a AnyString>>
|
fn name<'a>(&'a self) -> Option<OneOrMany<&'a AnyString>>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.base_ref().name.as_ref().map(|o| o.as_ref())
|
self.base_ref().name.as_ref().map(|o| o.as_ref())
|
||||||
}
|
}
|
||||||
|
@ -662,7 +666,7 @@ pub trait BaseExt<Kind>: AsBase<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn media_type<'a>(&'a self) -> Option<&'a Mime>
|
fn media_type<'a>(&'a self) -> Option<&'a Mime>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.base_ref().media_type.as_ref().map(|m| m.as_ref())
|
self.base_ref().media_type.as_ref().map(|m| m.as_ref())
|
||||||
}
|
}
|
||||||
|
@ -737,7 +741,7 @@ pub trait BaseExt<Kind>: AsBase<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn preview<'a>(&'a self) -> Option<OneOrMany<&'a AnyBase>>
|
fn preview<'a>(&'a self) -> Option<OneOrMany<&'a AnyBase>>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.base_ref().preview.as_ref().map(|o| o.as_ref())
|
self.base_ref().preview.as_ref().map(|o| o.as_ref())
|
||||||
}
|
}
|
||||||
|
@ -1047,7 +1051,7 @@ impl<Kind> Base<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
pub fn extend<T>(self) -> Result<T, T::Error>
|
pub fn extend<T>(self) -> Result<T, T::Error>
|
||||||
where
|
where
|
||||||
T: Extends<Kind>,
|
T: Extends<Kind = Kind>,
|
||||||
{
|
{
|
||||||
T::extends(self)
|
T::extends(self)
|
||||||
}
|
}
|
||||||
|
@ -1066,7 +1070,7 @@ impl<Kind> Base<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
pub fn retract<T>(t: T) -> Result<Self, T::Error>
|
pub fn retract<T>(t: T) -> Result<Self, T::Error>
|
||||||
where
|
where
|
||||||
T: Extends<Kind>,
|
T: Extends<Kind = Kind>,
|
||||||
{
|
{
|
||||||
t.retracts()
|
t.retracts()
|
||||||
}
|
}
|
||||||
|
@ -1170,7 +1174,7 @@ impl AnyBase {
|
||||||
Ok(base.into())
|
Ok(base.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extend this AnyBase into a kind T where T implements Extends<Kind>
|
/// Extend this AnyBase into a kind T where T implements Extends
|
||||||
///
|
///
|
||||||
/// This method returns Ok(None) when the AnyBase does not contain an extensible object, i.e.
|
/// This method returns Ok(None) when the AnyBase does not contain an extensible object, i.e.
|
||||||
/// it's just an IRI
|
/// it's just an IRI
|
||||||
|
@ -1186,8 +1190,8 @@ impl AnyBase {
|
||||||
/// ```
|
/// ```
|
||||||
pub fn extend<T, Kind>(self) -> Result<Option<T>, T::Error>
|
pub fn extend<T, Kind>(self) -> Result<Option<T>, T::Error>
|
||||||
where
|
where
|
||||||
T: ExtendsExt<Kind>,
|
T: ExtendsExt<Kind = Kind>,
|
||||||
<T as Extends<Kind>>::Error: From<serde_json::Error>,
|
<T as Extends>::Error: From<serde_json::Error>,
|
||||||
for<'de> Kind: serde::Deserialize<'de>,
|
for<'de> Kind: serde::Deserialize<'de>,
|
||||||
{
|
{
|
||||||
T::from_any_base(self)
|
T::from_any_base(self)
|
||||||
|
@ -1205,7 +1209,7 @@ impl AnyBase {
|
||||||
/// ```
|
/// ```
|
||||||
pub fn from_extended<T, Kind>(extended: T) -> Result<Self, T::Error>
|
pub fn from_extended<T, Kind>(extended: T) -> Result<Self, T::Error>
|
||||||
where
|
where
|
||||||
T: Extends<Kind>,
|
T: Extends<Kind = Kind>,
|
||||||
T::Error: From<serde_json::Error>,
|
T::Error: From<serde_json::Error>,
|
||||||
Kind: serde::ser::Serialize,
|
Kind: serde::ser::Serialize,
|
||||||
{
|
{
|
||||||
|
@ -1936,35 +1940,38 @@ impl<Kind> UnparsedMut for Base<Kind> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Kind> AsBase<Kind> for Base<Kind> {
|
impl<Kind> AsBase for Base<Kind> {
|
||||||
fn base_ref(&self) -> &Base<Kind> {
|
type Kind = Kind;
|
||||||
|
|
||||||
|
fn base_ref(&self) -> &Base<Self::Kind> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn base_mut(&mut self) -> &mut Base<Kind> {
|
fn base_mut(&mut self) -> &mut Base<Self::Kind> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Kind> Extends<Kind> for Base<Kind> {
|
impl<Kind> Extends for Base<Kind> {
|
||||||
|
type Kind = Kind;
|
||||||
type Error = std::convert::Infallible;
|
type Error = std::convert::Infallible;
|
||||||
|
|
||||||
fn extends(base: Base<Kind>) -> Result<Self, Self::Error> {
|
fn extends(base: Base<Self::Kind>) -> Result<Self, Self::Error> {
|
||||||
Ok(base)
|
Ok(base)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn retracts(self) -> Result<Base<Kind>, Self::Error> {
|
fn retracts(self) -> Result<Base<Self::Kind>, Self::Error> {
|
||||||
Ok(self)
|
Ok(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, Kind> ExtendsExt<Kind> for T
|
impl<T> ExtendsExt for T
|
||||||
where
|
where
|
||||||
T: Extends<Kind>,
|
T: Extends,
|
||||||
T::Error: From<serde_json::Error>,
|
T::Error: From<serde_json::Error>,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
impl<T, Kind> BaseExt<Kind> for T where T: AsBase<Kind> {}
|
impl<T> BaseExt for T where T: AsBase {}
|
||||||
|
|
||||||
impl From<Base<serde_json::Value>> for AnyBase {
|
impl From<Base<serde_json::Value>> for AnyBase {
|
||||||
fn from(o: Base<serde_json::Value>) -> Self {
|
fn from(o: Base<serde_json::Value>) -> Self {
|
||||||
|
|
|
@ -38,17 +38,21 @@ use self::kind::*;
|
||||||
/// Implementation trait for deriving Collection methods for a type
|
/// Implementation trait for deriving Collection methods for a type
|
||||||
///
|
///
|
||||||
/// Any type implementing AsCollection will automatically gain methods provided by CollectionExt
|
/// Any type implementing AsCollection will automatically gain methods provided by CollectionExt
|
||||||
pub trait AsCollection<Kind>: markers::Collection {
|
pub trait AsCollection: markers::Collection {
|
||||||
fn collection_ref(&self) -> &Collection<Kind>;
|
type Kind;
|
||||||
fn collection_mut(&mut self) -> &mut Collection<Kind>;
|
|
||||||
|
fn collection_ref(&self) -> &Collection<Self::Kind>;
|
||||||
|
fn collection_mut(&mut self) -> &mut Collection<Self::Kind>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Implementation trait for deriving Collection methods for a type
|
/// Implementation trait for deriving Collection methods for a type
|
||||||
///
|
///
|
||||||
/// Any type implementing AsCollectionPage will automatically gain methods provided by CollectionPageExt
|
/// Any type implementing AsCollectionPage will automatically gain methods provided by CollectionPageExt
|
||||||
pub trait AsCollectionPage<Kind>: markers::CollectionPage {
|
pub trait AsCollectionPage: markers::CollectionPage {
|
||||||
fn collection_page_ref(&self) -> &CollectionPage<Kind>;
|
type Kind;
|
||||||
fn collection_page_mut(&mut self) -> &mut CollectionPage<Kind>;
|
|
||||||
|
fn collection_page_ref(&self) -> &CollectionPage<Self::Kind>;
|
||||||
|
fn collection_page_mut(&mut self) -> &mut CollectionPage<Self::Kind>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Implementation trait for deriving Collection methods for a type
|
/// Implementation trait for deriving Collection methods for a type
|
||||||
|
@ -66,7 +70,7 @@ pub trait AsOrderedCollectionPage: markers::CollectionPage {
|
||||||
///
|
///
|
||||||
/// Documentation for the fields related to these methods can be found on the
|
/// Documentation for the fields related to these methods can be found on the
|
||||||
/// `Collection` struct
|
/// `Collection` struct
|
||||||
pub trait CollectionExt<Kind>: AsCollection<Kind> {
|
pub trait CollectionExt: AsCollection {
|
||||||
/// Fetch the items for the current activity
|
/// Fetch the items for the current activity
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
|
@ -80,7 +84,7 @@ pub trait CollectionExt<Kind>: AsCollection<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn items<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
fn items<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.collection_ref().items.as_ref()
|
self.collection_ref().items.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -209,7 +213,7 @@ pub trait CollectionExt<Kind>: AsCollection<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn ordered_items<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
fn ordered_items<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.collection_ref().ordered_items.as_ref()
|
self.collection_ref().ordered_items.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -338,7 +342,7 @@ pub trait CollectionExt<Kind>: AsCollection<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn total_items<'a>(&'a self) -> Option<u64>
|
fn total_items<'a>(&'a self) -> Option<u64>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.collection_ref().total_items
|
self.collection_ref().total_items
|
||||||
}
|
}
|
||||||
|
@ -408,7 +412,7 @@ pub trait CollectionExt<Kind>: AsCollection<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn current<'a>(&'a self) -> Option<&'a AnyBase>
|
fn current<'a>(&'a self) -> Option<&'a AnyBase>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.collection_ref().current.as_ref()
|
self.collection_ref().current.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -484,7 +488,7 @@ pub trait CollectionExt<Kind>: AsCollection<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn first<'a>(&'a self) -> Option<&'a AnyBase>
|
fn first<'a>(&'a self) -> Option<&'a AnyBase>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.collection_ref().first.as_ref()
|
self.collection_ref().first.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -560,7 +564,7 @@ pub trait CollectionExt<Kind>: AsCollection<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn last<'a>(&'a self) -> Option<&'a AnyBase>
|
fn last<'a>(&'a self) -> Option<&'a AnyBase>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.collection_ref().last.as_ref()
|
self.collection_ref().last.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -629,7 +633,7 @@ pub trait CollectionExt<Kind>: AsCollection<Kind> {
|
||||||
///
|
///
|
||||||
/// Documentation for the fields related to these methods can be found on the
|
/// Documentation for the fields related to these methods can be found on the
|
||||||
/// `CollectionPage` struct
|
/// `CollectionPage` struct
|
||||||
pub trait CollectionPageExt<Kind>: AsCollectionPage<Kind> {
|
pub trait CollectionPageExt: AsCollectionPage {
|
||||||
/// Fetch the part_of field for the current object
|
/// Fetch the part_of field for the current object
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
|
@ -644,7 +648,7 @@ pub trait CollectionPageExt<Kind>: AsCollectionPage<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn part_of<'a>(&'a self) -> Option<&'a AnyBase>
|
fn part_of<'a>(&'a self) -> Option<&'a AnyBase>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.collection_page_ref().part_of.as_ref()
|
self.collection_page_ref().part_of.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -720,7 +724,7 @@ pub trait CollectionPageExt<Kind>: AsCollectionPage<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn next<'a>(&'a self) -> Option<&'a AnyBase>
|
fn next<'a>(&'a self) -> Option<&'a AnyBase>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.collection_page_ref().next.as_ref()
|
self.collection_page_ref().next.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -796,7 +800,7 @@ pub trait CollectionPageExt<Kind>: AsCollectionPage<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn prev<'a>(&'a self) -> Option<&'a AnyBase>
|
fn prev<'a>(&'a self) -> Option<&'a AnyBase>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.collection_page_ref().prev.as_ref()
|
self.collection_page_ref().prev.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -1281,15 +1285,17 @@ impl markers::CollectionPage for OrderedCollectionPage {}
|
||||||
impl<Inner> markers::Collection for ApObject<Inner> where Inner: markers::Collection {}
|
impl<Inner> markers::Collection for ApObject<Inner> where Inner: markers::Collection {}
|
||||||
impl<Inner> markers::CollectionPage for ApObject<Inner> where Inner: markers::CollectionPage {}
|
impl<Inner> markers::CollectionPage for ApObject<Inner> where Inner: markers::CollectionPage {}
|
||||||
|
|
||||||
impl<Kind> Extends<Kind> for Collection<Kind> {
|
impl<Kind> Extends for Collection<Kind> {
|
||||||
|
type Kind = Kind;
|
||||||
|
|
||||||
type Error = serde_json::Error;
|
type Error = serde_json::Error;
|
||||||
|
|
||||||
fn extends(base: Base<Kind>) -> Result<Self, Self::Error> {
|
fn extends(base: Base<Self::Kind>) -> Result<Self, Self::Error> {
|
||||||
let inner = Object::extends(base)?;
|
let inner = Object::extends(base)?;
|
||||||
Self::extending(inner)
|
Self::extending(inner)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn retracts(self) -> Result<Base<Kind>, Self::Error> {
|
fn retracts(self) -> Result<Base<Self::Kind>, Self::Error> {
|
||||||
let inner = self.retracting()?;
|
let inner = self.retracting()?;
|
||||||
inner.retracts()
|
inner.retracts()
|
||||||
}
|
}
|
||||||
|
@ -1311,15 +1317,17 @@ impl<Kind> TryFrom<Object<Kind>> for Collection<Kind> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Kind> Extends<Kind> for CollectionPage<Kind> {
|
impl<Kind> Extends for CollectionPage<Kind> {
|
||||||
|
type Kind = Kind;
|
||||||
|
|
||||||
type Error = serde_json::Error;
|
type Error = serde_json::Error;
|
||||||
|
|
||||||
fn extends(base: Base<Kind>) -> Result<Self, Self::Error> {
|
fn extends(base: Base<Self::Kind>) -> Result<Self, Self::Error> {
|
||||||
let inner = Object::extends(base)?;
|
let inner = Object::extends(base)?;
|
||||||
Self::extending(inner)
|
Self::extending(inner)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn retracts(self) -> Result<Base<Kind>, Self::Error> {
|
fn retracts(self) -> Result<Base<Self::Kind>, Self::Error> {
|
||||||
let inner = self.retracting()?;
|
let inner = self.retracting()?;
|
||||||
inner.retracts()
|
inner.retracts()
|
||||||
}
|
}
|
||||||
|
@ -1341,7 +1349,9 @@ impl<Kind> TryFrom<CollectionPage<Kind>> for Object<Kind> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Extends<OrderedCollectionPageType> for OrderedCollectionPage {
|
impl Extends for OrderedCollectionPage {
|
||||||
|
type Kind = OrderedCollectionPageType;
|
||||||
|
|
||||||
type Error = serde_json::Error;
|
type Error = serde_json::Error;
|
||||||
|
|
||||||
fn extends(base: Base<OrderedCollectionPageType>) -> Result<Self, Self::Error> {
|
fn extends(base: Base<OrderedCollectionPageType>) -> Result<Self, Self::Error> {
|
||||||
|
@ -1389,77 +1399,93 @@ impl UnparsedMut for OrderedCollectionPage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Kind> AsBase<Kind> for Collection<Kind> {
|
impl<Kind> AsBase for Collection<Kind> {
|
||||||
fn base_ref(&self) -> &Base<Kind> {
|
type Kind = Kind;
|
||||||
|
|
||||||
|
fn base_ref(&self) -> &Base<Self::Kind> {
|
||||||
self.inner.base_ref()
|
self.inner.base_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn base_mut(&mut self) -> &mut Base<Kind> {
|
fn base_mut(&mut self) -> &mut Base<Self::Kind> {
|
||||||
self.inner.base_mut()
|
self.inner.base_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Kind> AsObject<Kind> for Collection<Kind> {
|
impl<Kind> AsObject for Collection<Kind> {
|
||||||
fn object_ref(&self) -> &Object<Kind> {
|
type Kind = Kind;
|
||||||
|
|
||||||
|
fn object_ref(&self) -> &Object<Self::Kind> {
|
||||||
&self.inner
|
&self.inner
|
||||||
}
|
}
|
||||||
|
|
||||||
fn object_mut(&mut self) -> &mut Object<Kind> {
|
fn object_mut(&mut self) -> &mut Object<Self::Kind> {
|
||||||
&mut self.inner
|
&mut self.inner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Kind> AsCollection<Kind> for Collection<Kind> {
|
impl<Kind> AsCollection for Collection<Kind> {
|
||||||
fn collection_ref(&self) -> &Collection<Kind> {
|
type Kind = Kind;
|
||||||
|
|
||||||
|
fn collection_ref(&self) -> &Collection<Self::Kind> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collection_mut(&mut self) -> &mut Collection<Kind> {
|
fn collection_mut(&mut self) -> &mut Collection<Self::Kind> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Kind> AsBase<Kind> for CollectionPage<Kind> {
|
impl<Kind> AsBase for CollectionPage<Kind> {
|
||||||
fn base_ref(&self) -> &Base<Kind> {
|
type Kind = Kind;
|
||||||
|
|
||||||
|
fn base_ref(&self) -> &Base<Self::Kind> {
|
||||||
self.inner.base_ref()
|
self.inner.base_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn base_mut(&mut self) -> &mut Base<Kind> {
|
fn base_mut(&mut self) -> &mut Base<Self::Kind> {
|
||||||
self.inner.base_mut()
|
self.inner.base_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Kind> AsObject<Kind> for CollectionPage<Kind> {
|
impl<Kind> AsObject for CollectionPage<Kind> {
|
||||||
fn object_ref(&self) -> &Object<Kind> {
|
type Kind = Kind;
|
||||||
|
|
||||||
|
fn object_ref(&self) -> &Object<Self::Kind> {
|
||||||
self.inner.object_ref()
|
self.inner.object_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn object_mut(&mut self) -> &mut Object<Kind> {
|
fn object_mut(&mut self) -> &mut Object<Self::Kind> {
|
||||||
self.inner.object_mut()
|
self.inner.object_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Kind> AsCollection<Kind> for CollectionPage<Kind> {
|
impl<Kind> AsCollection for CollectionPage<Kind> {
|
||||||
fn collection_ref(&self) -> &Collection<Kind> {
|
type Kind = Kind;
|
||||||
|
|
||||||
|
fn collection_ref(&self) -> &Collection<Self::Kind> {
|
||||||
&self.inner
|
&self.inner
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collection_mut(&mut self) -> &mut Collection<Kind> {
|
fn collection_mut(&mut self) -> &mut Collection<Self::Kind> {
|
||||||
&mut self.inner
|
&mut self.inner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Kind> AsCollectionPage<Kind> for CollectionPage<Kind> {
|
impl<Kind> AsCollectionPage for CollectionPage<Kind> {
|
||||||
fn collection_page_ref(&self) -> &CollectionPage<Kind> {
|
type Kind = Kind;
|
||||||
|
|
||||||
|
fn collection_page_ref(&self) -> &CollectionPage<Self::Kind> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collection_page_mut(&mut self) -> &mut CollectionPage<Kind> {
|
fn collection_page_mut(&mut self) -> &mut CollectionPage<Self::Kind> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsBase<OrderedCollectionPageType> for OrderedCollectionPage {
|
impl AsBase for OrderedCollectionPage {
|
||||||
|
type Kind = OrderedCollectionPageType;
|
||||||
|
|
||||||
fn base_ref(&self) -> &Base<OrderedCollectionPageType> {
|
fn base_ref(&self) -> &Base<OrderedCollectionPageType> {
|
||||||
self.inner.base_ref()
|
self.inner.base_ref()
|
||||||
}
|
}
|
||||||
|
@ -1469,7 +1495,9 @@ impl AsBase<OrderedCollectionPageType> for OrderedCollectionPage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsObject<OrderedCollectionPageType> for OrderedCollectionPage {
|
impl AsObject for OrderedCollectionPage {
|
||||||
|
type Kind = OrderedCollectionPageType;
|
||||||
|
|
||||||
fn object_ref(&self) -> &Object<OrderedCollectionPageType> {
|
fn object_ref(&self) -> &Object<OrderedCollectionPageType> {
|
||||||
self.inner.object_ref()
|
self.inner.object_ref()
|
||||||
}
|
}
|
||||||
|
@ -1479,7 +1507,9 @@ impl AsObject<OrderedCollectionPageType> for OrderedCollectionPage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsCollection<OrderedCollectionPageType> for OrderedCollectionPage {
|
impl AsCollection for OrderedCollectionPage {
|
||||||
|
type Kind = OrderedCollectionPageType;
|
||||||
|
|
||||||
fn collection_ref(&self) -> &Collection<OrderedCollectionPageType> {
|
fn collection_ref(&self) -> &Collection<OrderedCollectionPageType> {
|
||||||
self.inner.collection_ref()
|
self.inner.collection_ref()
|
||||||
}
|
}
|
||||||
|
@ -1489,7 +1519,9 @@ impl AsCollection<OrderedCollectionPageType> for OrderedCollectionPage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsCollectionPage<OrderedCollectionPageType> for OrderedCollectionPage {
|
impl AsCollectionPage for OrderedCollectionPage {
|
||||||
|
type Kind = OrderedCollectionPageType;
|
||||||
|
|
||||||
fn collection_page_ref(&self) -> &CollectionPage<OrderedCollectionPageType> {
|
fn collection_page_ref(&self) -> &CollectionPage<OrderedCollectionPageType> {
|
||||||
&self.inner
|
&self.inner
|
||||||
}
|
}
|
||||||
|
@ -1509,28 +1541,32 @@ impl AsOrderedCollectionPage for OrderedCollectionPage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, Kind> AsCollection<Kind> for ApObject<Inner>
|
impl<Inner> AsCollection for ApObject<Inner>
|
||||||
where
|
where
|
||||||
Inner: AsCollection<Kind>,
|
Inner: AsCollection,
|
||||||
{
|
{
|
||||||
fn collection_ref(&self) -> &Collection<Kind> {
|
type Kind = Inner::Kind;
|
||||||
|
|
||||||
|
fn collection_ref(&self) -> &Collection<Self::Kind> {
|
||||||
self.inner().collection_ref()
|
self.inner().collection_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collection_mut(&mut self) -> &mut Collection<Kind> {
|
fn collection_mut(&mut self) -> &mut Collection<Self::Kind> {
|
||||||
self.inner_mut().collection_mut()
|
self.inner_mut().collection_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, Kind> AsCollectionPage<Kind> for ApObject<Inner>
|
impl<Inner> AsCollectionPage for ApObject<Inner>
|
||||||
where
|
where
|
||||||
Inner: AsCollectionPage<Kind>,
|
Inner: AsCollectionPage,
|
||||||
{
|
{
|
||||||
fn collection_page_ref(&self) -> &CollectionPage<Kind> {
|
type Kind = Inner::Kind;
|
||||||
|
|
||||||
|
fn collection_page_ref(&self) -> &CollectionPage<Self::Kind> {
|
||||||
self.inner().collection_page_ref()
|
self.inner().collection_page_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collection_page_mut(&mut self) -> &mut CollectionPage<Kind> {
|
fn collection_page_mut(&mut self) -> &mut CollectionPage<Self::Kind> {
|
||||||
self.inner_mut().collection_page_mut()
|
self.inner_mut().collection_page_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1548,8 +1584,8 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, Kind> CollectionExt<Kind> for T where T: AsCollection<Kind> {}
|
impl<T> CollectionExt for T where T: AsCollection {}
|
||||||
impl<T, Kind> CollectionPageExt<Kind> for T where T: AsCollectionPage<Kind> {}
|
impl<T> CollectionPageExt for T where T: AsCollectionPage {}
|
||||||
impl<T> OrderedCollectionPageExt for T where T: AsOrderedCollectionPage {}
|
impl<T> OrderedCollectionPageExt for T where T: AsOrderedCollectionPage {}
|
||||||
|
|
||||||
impl<Kind> Default for Collection<Kind>
|
impl<Kind> Default for Collection<Kind>
|
||||||
|
|
14
src/lib.rs
14
src/lib.rs
|
@ -1,10 +1,10 @@
|
||||||
//! # ActivityStreams New
|
//! # ActivityStreams New
|
||||||
//! _A set of Traits and Types that make up the ActivityStreams and ActivityPub specifications_
|
//! _A set of Traits and Types that make up the ActivityStreams and ActivityPub specifications_
|
||||||
//!
|
//!
|
||||||
//! - Find the code on [git.asonix.dog](https://git.asonix.dog/Aardwolf/activitystreams)
|
//! - Find the code on [git.asonix.dog](https://git.asonix.dog/asonix/activitystreams)
|
||||||
//! - Read the docs on [docs.rs](https://docs.rs/activitystreams)
|
//! - Read the docs on [docs.rs](https://docs.rs/activitystreams)
|
||||||
//! - Join the matrix channel at [#activitypub:asonix.dog](https://matrix.to/#/!fAEcHyTUdAaKCzIKCt:asonix.dog?via=asonix.dog&via=matrix.org&via=t2bot.io)
|
//! - Join the matrix channel at [#activitypub:matrix.asonix.dog](https://matrix.to/#/!fAEcHyTUdAaKCzIKCt:asonix.dog?via=asonix.dog&via=matrix.org&via=t2bot.io)
|
||||||
//! - Hit me up on [mastodon](https://asonix.dog/@asonix)
|
//! - Hit me up on [mastodon](https://masto.asonix.dog/@asonix)
|
||||||
//!
|
//!
|
||||||
//! ## Usage
|
//! ## Usage
|
||||||
//!
|
//!
|
||||||
|
@ -166,9 +166,9 @@
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! use activitystreams::{base::BaseExt, context, markers::Activity, iri};
|
//! use activitystreams::{base::BaseExt, context, markers::Activity, iri};
|
||||||
//!
|
//!
|
||||||
//! fn manipulator<T, Kind>(mut activity: T) -> Result<(), anyhow::Error>
|
//! fn manipulator<T>(mut activity: T) -> Result<(), anyhow::Error>
|
||||||
//! where
|
//! where
|
||||||
//! T: Activity + BaseExt<Kind>,
|
//! T: Activity + BaseExt,
|
||||||
//! {
|
//! {
|
||||||
//! activity
|
//! activity
|
||||||
//! .set_id(iri!("https://example.com"))
|
//! .set_id(iri!("https://example.com"))
|
||||||
|
@ -375,8 +375,8 @@ pub mod prelude {
|
||||||
|
|
||||||
pub use crate::{
|
pub use crate::{
|
||||||
activity::{
|
activity::{
|
||||||
ActivityExt, ActorAndObjectRefExt, OptOriginRefExt, OptTargetRefExt, OriginRefExt,
|
ActivityExt, AsActivityActorExt, AsActivityObjectExt, AsOptOriginExt, AsOptTargetExt,
|
||||||
QuestionExt, TargetRefExt,
|
AsOriginExt, AsTargetExt, QuestionExt,
|
||||||
},
|
},
|
||||||
actor::ApActorExt,
|
actor::ApActorExt,
|
||||||
base::{BaseExt, ExtendsExt},
|
base::{BaseExt, ExtendsExt},
|
||||||
|
|
45
src/link.rs
45
src/link.rs
|
@ -36,12 +36,13 @@ use self::kind::MentionType;
|
||||||
/// Implementation trait for deriving Link methods for a type
|
/// Implementation trait for deriving Link methods for a type
|
||||||
///
|
///
|
||||||
/// Any type implementing AsLink will automatically gain methods provided by LinkExt
|
/// Any type implementing AsLink will automatically gain methods provided by LinkExt
|
||||||
pub trait AsLink<Kind>: markers::Link {
|
pub trait AsLink: markers::Link {
|
||||||
|
type Kind;
|
||||||
/// Immutable borrow of `Link<Kind>`
|
/// Immutable borrow of `Link<Kind>`
|
||||||
fn link_ref(&self) -> &Link<Kind>;
|
fn link_ref(&self) -> &Link<Self::Kind>;
|
||||||
|
|
||||||
/// Mutable borrow of `Link<Kind>`
|
/// Mutable borrow of `Link<Kind>`
|
||||||
fn link_mut(&mut self) -> &mut Link<Kind>;
|
fn link_mut(&mut self) -> &mut Link<Self::Kind>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper methods for interacting with Link types
|
/// Helper methods for interacting with Link types
|
||||||
|
@ -49,7 +50,7 @@ pub trait AsLink<Kind>: markers::Link {
|
||||||
/// This trait represents methods valid for any ActivityStreams Link.
|
/// This trait represents methods valid for any ActivityStreams Link.
|
||||||
///
|
///
|
||||||
/// Documentation for the fields related to these methods can be found on the `Link` struct
|
/// Documentation for the fields related to these methods can be found on the `Link` struct
|
||||||
pub trait LinkExt<Kind>: AsLink<Kind> {
|
pub trait LinkExt: AsLink {
|
||||||
/// Fetch the href for the current object
|
/// Fetch the href for the current object
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
|
@ -62,7 +63,7 @@ pub trait LinkExt<Kind>: AsLink<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn href<'a>(&'a self) -> Option<&'a IriString>
|
fn href<'a>(&'a self) -> Option<&'a IriString>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.link_ref().href.as_ref()
|
self.link_ref().href.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -136,7 +137,7 @@ pub trait LinkExt<Kind>: AsLink<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn hreflang<'a>(&'a self) -> Option<&'a str>
|
fn hreflang<'a>(&'a self) -> Option<&'a str>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.link_ref().hreflang.as_deref()
|
self.link_ref().hreflang.as_deref()
|
||||||
}
|
}
|
||||||
|
@ -210,7 +211,7 @@ pub trait LinkExt<Kind>: AsLink<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn rel<'a>(&'a self) -> Option<&'a OneOrMany<String>>
|
fn rel<'a>(&'a self) -> Option<&'a OneOrMany<String>>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.link_ref().rel.as_ref()
|
self.link_ref().rel.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -330,7 +331,7 @@ pub trait LinkExt<Kind>: AsLink<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn height<'a>(&'a self) -> Option<u64>
|
fn height<'a>(&'a self) -> Option<u64>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.link_ref().height
|
self.link_ref().height
|
||||||
}
|
}
|
||||||
|
@ -403,7 +404,7 @@ pub trait LinkExt<Kind>: AsLink<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn width<'a>(&'a self) -> Option<u64>
|
fn width<'a>(&'a self) -> Option<u64>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.link_ref().width
|
self.link_ref().width
|
||||||
}
|
}
|
||||||
|
@ -618,14 +619,16 @@ impl<Kind> Link<Kind> {
|
||||||
impl<Kind> markers::Base for Link<Kind> {}
|
impl<Kind> markers::Base for Link<Kind> {}
|
||||||
impl<Kind> markers::Link for Link<Kind> {}
|
impl<Kind> markers::Link for Link<Kind> {}
|
||||||
|
|
||||||
impl<Kind> Extends<Kind> for Link<Kind> {
|
impl<Kind> Extends for Link<Kind> {
|
||||||
|
type Kind = Kind;
|
||||||
|
|
||||||
type Error = serde_json::Error;
|
type Error = serde_json::Error;
|
||||||
|
|
||||||
fn extends(base: Base<Kind>) -> Result<Self, Self::Error> {
|
fn extends(base: Base<Self::Kind>) -> Result<Self, Self::Error> {
|
||||||
Self::extending(base)
|
Self::extending(base)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn retracts(self) -> Result<Base<Kind>, Self::Error> {
|
fn retracts(self) -> Result<Base<Self::Kind>, Self::Error> {
|
||||||
self.retracting()
|
self.retracting()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -658,27 +661,31 @@ impl<Kind> UnparsedMut for Link<Kind> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Kind> AsBase<Kind> for Link<Kind> {
|
impl<Kind> AsBase for Link<Kind> {
|
||||||
fn base_ref(&self) -> &Base<Kind> {
|
type Kind = Kind;
|
||||||
|
|
||||||
|
fn base_ref(&self) -> &Base<Self::Kind> {
|
||||||
&self.inner
|
&self.inner
|
||||||
}
|
}
|
||||||
|
|
||||||
fn base_mut(&mut self) -> &mut Base<Kind> {
|
fn base_mut(&mut self) -> &mut Base<Self::Kind> {
|
||||||
&mut self.inner
|
&mut self.inner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Kind> AsLink<Kind> for Link<Kind> {
|
impl<Kind> AsLink for Link<Kind> {
|
||||||
fn link_ref(&self) -> &Link<Kind> {
|
type Kind = Kind;
|
||||||
|
|
||||||
|
fn link_ref(&self) -> &Link<Self::Kind> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn link_mut(&mut self) -> &mut Link<Kind> {
|
fn link_mut(&mut self) -> &mut Link<Self::Kind> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, Kind> LinkExt<Kind> for T where T: AsLink<Kind> {}
|
impl<T> LinkExt for T where T: AsLink {}
|
||||||
|
|
||||||
impl<Kind> Default for Link<Kind>
|
impl<Kind> Default for Link<Kind>
|
||||||
where
|
where
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
//! use activitystreams::{base::BaseExt, markers::Activity};
|
//! use activitystreams::{base::BaseExt, markers::Activity};
|
||||||
//!
|
//!
|
||||||
//! /// Applies the name "hi" to any given activity
|
//! /// Applies the name "hi" to any given activity
|
||||||
//! fn manipulator<T, Kind>(mut some_type: T) -> T
|
//! fn manipulator<T>(mut some_type: T) -> T
|
||||||
//! where
|
//! where
|
||||||
//! T: Activity + BaseExt<Kind>,
|
//! T: Activity + BaseExt,
|
||||||
//! {
|
//! {
|
||||||
//! some_type.set_name("hi");
|
//! some_type.set_name("hi");
|
||||||
//!
|
//!
|
||||||
|
|
154
src/object.rs
154
src/object.rs
|
@ -36,12 +36,14 @@ use self::kind::*;
|
||||||
/// Implementation trait for deriving Object methods for a type
|
/// Implementation trait for deriving Object methods for a type
|
||||||
///
|
///
|
||||||
/// Any type implementing AsObject will automatically gain methods provided by ObjectExt
|
/// Any type implementing AsObject will automatically gain methods provided by ObjectExt
|
||||||
pub trait AsObject<Kind>: markers::Object {
|
pub trait AsObject: markers::Object {
|
||||||
|
type Kind;
|
||||||
|
|
||||||
/// Immutable borrow of `Object<Kind>`
|
/// Immutable borrow of `Object<Kind>`
|
||||||
fn object_ref(&self) -> &Object<Kind>;
|
fn object_ref(&self) -> &Object<Self::Kind>;
|
||||||
|
|
||||||
/// Mutable borrow of `Object<Kind>`
|
/// Mutable borrow of `Object<Kind>`
|
||||||
fn object_mut(&mut self) -> &mut Object<Kind>;
|
fn object_mut(&mut self) -> &mut Object<Self::Kind>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Implementation trait for deriving ActivityPub Object methods for a type
|
/// Implementation trait for deriving ActivityPub Object methods for a type
|
||||||
|
@ -105,7 +107,7 @@ pub trait AsTombstone: markers::Object {
|
||||||
/// This trait represents methods valid for any ActivityStreams Object.
|
/// This trait represents methods valid for any ActivityStreams Object.
|
||||||
///
|
///
|
||||||
/// Documentation for the fields related to these methods can be found on the `Object` struct
|
/// Documentation for the fields related to these methods can be found on the `Object` struct
|
||||||
pub trait ObjectExt<Kind>: AsObject<Kind> {
|
pub trait ObjectExt: AsObject {
|
||||||
/// Fetch the attachment for the current object
|
/// Fetch the attachment for the current object
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
|
@ -120,7 +122,7 @@ pub trait ObjectExt<Kind>: AsObject<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn attachment<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
fn attachment<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.object_ref().attachment.as_ref()
|
self.object_ref().attachment.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -256,7 +258,7 @@ pub trait ObjectExt<Kind>: AsObject<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn attributed_to<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
fn attributed_to<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.object_ref().attributed_to.as_ref()
|
self.object_ref().attributed_to.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -392,7 +394,7 @@ pub trait ObjectExt<Kind>: AsObject<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn audience<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
fn audience<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.object_ref().audience.as_ref()
|
self.object_ref().audience.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -526,7 +528,7 @@ pub trait ObjectExt<Kind>: AsObject<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn content<'a>(&'a self) -> Option<OneOrMany<&'a AnyString>>
|
fn content<'a>(&'a self) -> Option<OneOrMany<&'a AnyString>>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.object_ref().content.as_ref().map(|o| o.as_ref())
|
self.object_ref().content.as_ref().map(|o| o.as_ref())
|
||||||
}
|
}
|
||||||
|
@ -647,7 +649,7 @@ pub trait ObjectExt<Kind>: AsObject<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn summary<'a>(&'a self) -> Option<OneOrMany<&'a AnyString>>
|
fn summary<'a>(&'a self) -> Option<OneOrMany<&'a AnyString>>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.object_ref().summary.as_ref().map(|o| o.as_ref())
|
self.object_ref().summary.as_ref().map(|o| o.as_ref())
|
||||||
}
|
}
|
||||||
|
@ -768,7 +770,7 @@ pub trait ObjectExt<Kind>: AsObject<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn url<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
fn url<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.object_ref().url.as_ref()
|
self.object_ref().url.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -904,7 +906,7 @@ pub trait ObjectExt<Kind>: AsObject<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn generator<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
fn generator<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.object_ref().generator.as_ref()
|
self.object_ref().generator.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -1040,7 +1042,7 @@ pub trait ObjectExt<Kind>: AsObject<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn icon<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
fn icon<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.object_ref().icon.as_ref()
|
self.object_ref().icon.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -1176,7 +1178,7 @@ pub trait ObjectExt<Kind>: AsObject<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn image<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
fn image<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.object_ref().image.as_ref()
|
self.object_ref().image.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -1312,7 +1314,7 @@ pub trait ObjectExt<Kind>: AsObject<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn location<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
fn location<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.object_ref().location.as_ref()
|
self.object_ref().location.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -1448,7 +1450,7 @@ pub trait ObjectExt<Kind>: AsObject<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn tag<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
fn tag<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.object_ref().tag.as_ref()
|
self.object_ref().tag.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -1584,7 +1586,7 @@ pub trait ObjectExt<Kind>: AsObject<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn start_time<'a>(&'a self) -> Option<OffsetDateTime>
|
fn start_time<'a>(&'a self) -> Option<OffsetDateTime>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.object_ref()
|
self.object_ref()
|
||||||
.start_time
|
.start_time
|
||||||
|
@ -1662,7 +1664,7 @@ pub trait ObjectExt<Kind>: AsObject<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn end_time<'a>(&'a self) -> Option<OffsetDateTime>
|
fn end_time<'a>(&'a self) -> Option<OffsetDateTime>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.object_ref()
|
self.object_ref()
|
||||||
.end_time
|
.end_time
|
||||||
|
@ -1740,7 +1742,7 @@ pub trait ObjectExt<Kind>: AsObject<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn duration<'a>(&'a self) -> Option<Duration>
|
fn duration<'a>(&'a self) -> Option<Duration>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.object_ref()
|
self.object_ref()
|
||||||
.duration
|
.duration
|
||||||
|
@ -1820,7 +1822,7 @@ pub trait ObjectExt<Kind>: AsObject<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn published<'a>(&'a self) -> Option<OffsetDateTime>
|
fn published<'a>(&'a self) -> Option<OffsetDateTime>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.object_ref()
|
self.object_ref()
|
||||||
.published
|
.published
|
||||||
|
@ -1898,7 +1900,7 @@ pub trait ObjectExt<Kind>: AsObject<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn updated<'a>(&'a self) -> Option<OffsetDateTime>
|
fn updated<'a>(&'a self) -> Option<OffsetDateTime>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.object_ref()
|
self.object_ref()
|
||||||
.updated
|
.updated
|
||||||
|
@ -1976,7 +1978,7 @@ pub trait ObjectExt<Kind>: AsObject<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn in_reply_to<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
fn in_reply_to<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.object_ref().in_reply_to.as_ref()
|
self.object_ref().in_reply_to.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -2112,7 +2114,7 @@ pub trait ObjectExt<Kind>: AsObject<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn replies<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
fn replies<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.object_ref().replies.as_ref()
|
self.object_ref().replies.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -2248,7 +2250,7 @@ pub trait ObjectExt<Kind>: AsObject<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn to<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
fn to<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.object_ref().to.as_ref()
|
self.object_ref().to.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -2384,7 +2386,7 @@ pub trait ObjectExt<Kind>: AsObject<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn bto<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
fn bto<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.object_ref().bto.as_ref()
|
self.object_ref().bto.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -2520,7 +2522,7 @@ pub trait ObjectExt<Kind>: AsObject<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn cc<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
fn cc<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.object_ref().cc.as_ref()
|
self.object_ref().cc.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -2656,7 +2658,7 @@ pub trait ObjectExt<Kind>: AsObject<Kind> {
|
||||||
/// ```
|
/// ```
|
||||||
fn bcc<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
fn bcc<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
|
||||||
where
|
where
|
||||||
Kind: 'a,
|
Self::Kind: 'a,
|
||||||
{
|
{
|
||||||
self.object_ref().bcc.as_ref()
|
self.object_ref().bcc.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -5131,14 +5133,16 @@ impl Tombstone {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Kind> Extends<Kind> for Object<Kind> {
|
impl<Kind> Extends for Object<Kind> {
|
||||||
|
type Kind = Kind;
|
||||||
|
|
||||||
type Error = serde_json::Error;
|
type Error = serde_json::Error;
|
||||||
|
|
||||||
fn extends(base: Base<Kind>) -> Result<Self, Self::Error> {
|
fn extends(base: Base<Self::Kind>) -> Result<Self, Self::Error> {
|
||||||
Self::extending(base)
|
Self::extending(base)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn retracts(self) -> Result<Base<Kind>, Self::Error> {
|
fn retracts(self) -> Result<Base<Self::Kind>, Self::Error> {
|
||||||
self.retracting()
|
self.retracting()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5159,24 +5163,26 @@ impl<Kind> TryFrom<Object<Kind>> for Base<Kind> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, Kind> Extends<Kind> for ApObject<Inner>
|
impl<Inner> Extends for ApObject<Inner>
|
||||||
where
|
where
|
||||||
Inner: Extends<Kind, Error = serde_json::Error> + UnparsedMut + markers::Object,
|
Inner: Extends<Error = serde_json::Error> + UnparsedMut + markers::Object,
|
||||||
{
|
{
|
||||||
|
type Kind = Inner::Kind;
|
||||||
type Error = serde_json::Error;
|
type Error = serde_json::Error;
|
||||||
|
|
||||||
fn extends(base: Base<Kind>) -> Result<Self, Self::Error> {
|
fn extends(base: Base<Self::Kind>) -> Result<Self, Self::Error> {
|
||||||
let inner = Inner::extends(base)?;
|
let inner = Inner::extends(base)?;
|
||||||
Self::extending(inner)
|
Self::extending(inner)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn retracts(self) -> Result<Base<Kind>, Self::Error> {
|
fn retracts(self) -> Result<Base<Self::Kind>, Self::Error> {
|
||||||
let inner = self.retracting()?;
|
let inner = self.retracting()?;
|
||||||
inner.retracts()
|
inner.retracts()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Extends<PlaceType> for Place {
|
impl Extends for Place {
|
||||||
|
type Kind = PlaceType;
|
||||||
type Error = serde_json::Error;
|
type Error = serde_json::Error;
|
||||||
|
|
||||||
fn extends(base: Base<PlaceType>) -> Result<Self, Self::Error> {
|
fn extends(base: Base<PlaceType>) -> Result<Self, Self::Error> {
|
||||||
|
@ -5206,7 +5212,8 @@ impl TryFrom<Place> for Object<PlaceType> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Extends<ProfileType> for Profile {
|
impl Extends for Profile {
|
||||||
|
type Kind = ProfileType;
|
||||||
type Error = serde_json::Error;
|
type Error = serde_json::Error;
|
||||||
|
|
||||||
fn extends(base: Base<ProfileType>) -> Result<Self, Self::Error> {
|
fn extends(base: Base<ProfileType>) -> Result<Self, Self::Error> {
|
||||||
|
@ -5236,7 +5243,8 @@ impl TryFrom<Profile> for Object<ProfileType> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Extends<RelationshipType> for Relationship {
|
impl Extends for Relationship {
|
||||||
|
type Kind = RelationshipType;
|
||||||
type Error = serde_json::Error;
|
type Error = serde_json::Error;
|
||||||
|
|
||||||
fn extends(base: Base<RelationshipType>) -> Result<Self, Self::Error> {
|
fn extends(base: Base<RelationshipType>) -> Result<Self, Self::Error> {
|
||||||
|
@ -5266,7 +5274,9 @@ impl TryFrom<Relationship> for Object<RelationshipType> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Extends<TombstoneType> for Tombstone {
|
impl Extends for Tombstone {
|
||||||
|
type Kind = TombstoneType;
|
||||||
|
|
||||||
type Error = serde_json::Error;
|
type Error = serde_json::Error;
|
||||||
|
|
||||||
fn extends(base: Base<TombstoneType>) -> Result<Self, Self::Error> {
|
fn extends(base: Base<TombstoneType>) -> Result<Self, Self::Error> {
|
||||||
|
@ -5353,55 +5363,63 @@ impl markers::Object for Relationship {}
|
||||||
impl markers::Base for Tombstone {}
|
impl markers::Base for Tombstone {}
|
||||||
impl markers::Object for Tombstone {}
|
impl markers::Object for Tombstone {}
|
||||||
|
|
||||||
impl<T, Kind> ObjectExt<Kind> for T where T: AsObject<Kind> {}
|
impl<T, Kind> ObjectExt for T where T: AsObject<Kind = Kind> {}
|
||||||
impl<T, Inner> ApObjectExt<Inner> for T where T: AsApObject<Inner> {}
|
impl<T, Inner> ApObjectExt<Inner> for T where T: AsApObject<Inner> {}
|
||||||
impl<T> PlaceExt for T where T: AsPlace {}
|
impl<T> PlaceExt for T where T: AsPlace {}
|
||||||
impl<T> ProfileExt for T where T: AsProfile {}
|
impl<T> ProfileExt for T where T: AsProfile {}
|
||||||
impl<T> RelationshipExt for T where T: AsRelationship {}
|
impl<T> RelationshipExt for T where T: AsRelationship {}
|
||||||
impl<T> TombstoneExt for T where T: AsTombstone {}
|
impl<T> TombstoneExt for T where T: AsTombstone {}
|
||||||
|
|
||||||
impl<Kind> AsBase<Kind> for Object<Kind> {
|
impl<Kind> AsBase for Object<Kind> {
|
||||||
fn base_ref(&self) -> &Base<Kind> {
|
type Kind = Kind;
|
||||||
|
|
||||||
|
fn base_ref(&self) -> &Base<Self::Kind> {
|
||||||
&self.inner
|
&self.inner
|
||||||
}
|
}
|
||||||
|
|
||||||
fn base_mut(&mut self) -> &mut Base<Kind> {
|
fn base_mut(&mut self) -> &mut Base<Self::Kind> {
|
||||||
&mut self.inner
|
&mut self.inner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Kind> AsObject<Kind> for Object<Kind> {
|
impl<Kind> AsObject for Object<Kind> {
|
||||||
fn object_ref(&self) -> &Object<Kind> {
|
type Kind = Kind;
|
||||||
|
|
||||||
|
fn object_ref(&self) -> &Object<Self::Kind> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn object_mut(&mut self) -> &mut Object<Kind> {
|
fn object_mut(&mut self) -> &mut Object<Self::Kind> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, Kind> AsBase<Kind> for ApObject<Inner>
|
impl<Inner> AsBase for ApObject<Inner>
|
||||||
where
|
where
|
||||||
Inner: AsBase<Kind>,
|
Inner: AsBase,
|
||||||
{
|
{
|
||||||
fn base_ref(&self) -> &Base<Kind> {
|
type Kind = Inner::Kind;
|
||||||
|
|
||||||
|
fn base_ref(&self) -> &Base<Self::Kind> {
|
||||||
self.inner.base_ref()
|
self.inner.base_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn base_mut(&mut self) -> &mut Base<Kind> {
|
fn base_mut(&mut self) -> &mut Base<Self::Kind> {
|
||||||
self.inner.base_mut()
|
self.inner.base_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Inner, Kind> AsObject<Kind> for ApObject<Inner>
|
impl<Inner> AsObject for ApObject<Inner>
|
||||||
where
|
where
|
||||||
Inner: AsObject<Kind>,
|
Inner: AsObject,
|
||||||
{
|
{
|
||||||
fn object_ref(&self) -> &Object<Kind> {
|
type Kind = Inner::Kind;
|
||||||
|
|
||||||
|
fn object_ref(&self) -> &Object<Self::Kind> {
|
||||||
self.inner.object_ref()
|
self.inner.object_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn object_mut(&mut self) -> &mut Object<Kind> {
|
fn object_mut(&mut self) -> &mut Object<Self::Kind> {
|
||||||
self.inner.object_mut()
|
self.inner.object_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5471,7 +5489,9 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsBase<PlaceType> for Place {
|
impl AsBase for Place {
|
||||||
|
type Kind = PlaceType;
|
||||||
|
|
||||||
fn base_ref(&self) -> &Base<PlaceType> {
|
fn base_ref(&self) -> &Base<PlaceType> {
|
||||||
self.inner.base_ref()
|
self.inner.base_ref()
|
||||||
}
|
}
|
||||||
|
@ -5481,7 +5501,9 @@ impl AsBase<PlaceType> for Place {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsObject<PlaceType> for Place {
|
impl AsObject for Place {
|
||||||
|
type Kind = PlaceType;
|
||||||
|
|
||||||
fn object_ref(&self) -> &Object<PlaceType> {
|
fn object_ref(&self) -> &Object<PlaceType> {
|
||||||
&self.inner
|
&self.inner
|
||||||
}
|
}
|
||||||
|
@ -5501,7 +5523,9 @@ impl AsPlace for Place {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsBase<ProfileType> for Profile {
|
impl AsBase for Profile {
|
||||||
|
type Kind = ProfileType;
|
||||||
|
|
||||||
fn base_ref(&self) -> &Base<ProfileType> {
|
fn base_ref(&self) -> &Base<ProfileType> {
|
||||||
self.inner.base_ref()
|
self.inner.base_ref()
|
||||||
}
|
}
|
||||||
|
@ -5511,7 +5535,9 @@ impl AsBase<ProfileType> for Profile {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsObject<ProfileType> for Profile {
|
impl AsObject for Profile {
|
||||||
|
type Kind = ProfileType;
|
||||||
|
|
||||||
fn object_ref(&self) -> &Object<ProfileType> {
|
fn object_ref(&self) -> &Object<ProfileType> {
|
||||||
&self.inner
|
&self.inner
|
||||||
}
|
}
|
||||||
|
@ -5531,7 +5557,9 @@ impl AsProfile for Profile {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsBase<RelationshipType> for Relationship {
|
impl AsBase for Relationship {
|
||||||
|
type Kind = RelationshipType;
|
||||||
|
|
||||||
fn base_ref(&self) -> &Base<RelationshipType> {
|
fn base_ref(&self) -> &Base<RelationshipType> {
|
||||||
self.inner.base_ref()
|
self.inner.base_ref()
|
||||||
}
|
}
|
||||||
|
@ -5541,7 +5569,9 @@ impl AsBase<RelationshipType> for Relationship {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsObject<RelationshipType> for Relationship {
|
impl AsObject for Relationship {
|
||||||
|
type Kind = RelationshipType;
|
||||||
|
|
||||||
fn object_ref(&self) -> &Object<RelationshipType> {
|
fn object_ref(&self) -> &Object<RelationshipType> {
|
||||||
&self.inner
|
&self.inner
|
||||||
}
|
}
|
||||||
|
@ -5561,7 +5591,9 @@ impl AsRelationship for Relationship {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsBase<TombstoneType> for Tombstone {
|
impl AsBase for Tombstone {
|
||||||
|
type Kind = TombstoneType;
|
||||||
|
|
||||||
fn base_ref(&self) -> &Base<TombstoneType> {
|
fn base_ref(&self) -> &Base<TombstoneType> {
|
||||||
self.inner.base_ref()
|
self.inner.base_ref()
|
||||||
}
|
}
|
||||||
|
@ -5571,7 +5603,9 @@ impl AsBase<TombstoneType> for Tombstone {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsObject<TombstoneType> for Tombstone {
|
impl AsObject for Tombstone {
|
||||||
|
type Kind = TombstoneType;
|
||||||
|
|
||||||
fn object_ref(&self) -> &Object<TombstoneType> {
|
fn object_ref(&self) -> &Object<TombstoneType> {
|
||||||
&self.inner
|
&self.inner
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,13 +46,14 @@
|
||||||
//!
|
//!
|
||||||
//! /// Then, we'll implement Extends so we can produce a PublicKey<Object> from an AnyBase.
|
//! /// Then, we'll implement Extends so we can produce a PublicKey<Object> from an AnyBase.
|
||||||
//!
|
//!
|
||||||
//! impl<Inner, Kind> Extends<Kind> for PublicKey<Inner>
|
//! impl<Inner> Extends for PublicKey<Inner>
|
||||||
//! where
|
//! where
|
||||||
//! Inner: Extends<Kind, Error=serde_json::Error> + UnparsedMut,
|
//! Inner: Extends<Error=serde_json::Error> + UnparsedMut,
|
||||||
//! {
|
//! {
|
||||||
|
//! type Kind = Inner::Kind;
|
||||||
//! type Error = serde_json::Error;
|
//! type Error = serde_json::Error;
|
||||||
//!
|
//!
|
||||||
//! fn extends(base: Base<Kind>) -> Result<Self, Self::Error> {
|
//! fn extends(base: Base<Self::Kind>) -> Result<Self, Self::Error> {
|
||||||
//! let mut inner = Inner::extends(base)?;
|
//! let mut inner = Inner::extends(base)?;
|
||||||
//!
|
//!
|
||||||
//! Ok(PublicKey {
|
//! Ok(PublicKey {
|
||||||
|
@ -61,7 +62,7 @@
|
||||||
//! })
|
//! })
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! fn retracts(self) -> Result<Base<Kind>, Self::Error> {
|
//! fn retracts(self) -> Result<Base<Self::Kind>, Self::Error> {
|
||||||
//! let PublicKey {
|
//! let PublicKey {
|
||||||
//! public_key,
|
//! public_key,
|
||||||
//! mut inner,
|
//! mut inner,
|
||||||
|
@ -87,15 +88,17 @@
|
||||||
//! ///
|
//! ///
|
||||||
//! /// This allows us to access methods related to `context`, `id`, `kind`, `name`,
|
//! /// This allows us to access methods related to `context`, `id`, `kind`, `name`,
|
||||||
//! /// `media_type`, and `preview` directly from the PublicKey struct
|
//! /// `media_type`, and `preview` directly from the PublicKey struct
|
||||||
//! impl<Inner, Kind> AsBase<Kind> for PublicKey<Inner>
|
//! impl<Inner> AsBase for PublicKey<Inner>
|
||||||
//! where
|
//! where
|
||||||
//! Inner: AsBase<Kind>,
|
//! Inner: AsBase,
|
||||||
//! {
|
//! {
|
||||||
//! fn base_ref(&self) -> &Base<Kind> {
|
//! type Kind = Inner::Kind;
|
||||||
|
//!
|
||||||
|
//! fn base_ref(&self) -> &Base<Self::Kind> {
|
||||||
//! self.inner.base_ref()
|
//! self.inner.base_ref()
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! fn base_mut(&mut self) -> &mut Base<Kind> {
|
//! fn base_mut(&mut self) -> &mut Base<Self::Kind> {
|
||||||
//! self.inner.base_mut()
|
//! self.inner.base_mut()
|
||||||
//! }
|
//! }
|
||||||
//! }
|
//! }
|
||||||
|
@ -104,15 +107,17 @@
|
||||||
//! ///
|
//! ///
|
||||||
//! /// This allows us to access methods related to `url`, `generator`, `start_time`, `duration`,
|
//! /// This allows us to access methods related to `url`, `generator`, `start_time`, `duration`,
|
||||||
//! /// and more directly from the PublicKey struct
|
//! /// and more directly from the PublicKey struct
|
||||||
//! impl<Inner, Kind> AsObject<Kind> for PublicKey<Inner>
|
//! impl<Inner> AsObject for PublicKey<Inner>
|
||||||
//! where
|
//! where
|
||||||
//! Inner: AsObject<Kind>,
|
//! Inner: AsObject,
|
||||||
//! {
|
//! {
|
||||||
//! fn object_ref(&self) -> &Object<Kind> {
|
//! type Kind = Inner::Kind;
|
||||||
|
//!
|
||||||
|
//! fn object_ref(&self) -> &Object<Self::Kind> {
|
||||||
//! self.inner.object_ref()
|
//! self.inner.object_ref()
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! fn object_mut(&mut self) -> &mut Object<Kind> {
|
//! fn object_mut(&mut self) -> &mut Object<Self::Kind> {
|
||||||
//! self.inner.object_mut()
|
//! self.inner.object_mut()
|
||||||
//! }
|
//! }
|
||||||
//! }
|
//! }
|
||||||
|
|
Loading…
Reference in a new issue