diff --git a/apub-core/src/activitystreams.rs b/apub-core/src/activitystreams.rs index b4f5933..fd8b5f8 100644 --- a/apub-core/src/activitystreams.rs +++ b/apub-core/src/activitystreams.rs @@ -96,6 +96,8 @@ pub trait Actor: Object { pub mod extensions { //! Extensions to the ActivityPub traits + use std::{rc::Rc, sync::Arc}; + use crate::{ repo::{Dereference, Repo}, session::Session, @@ -150,6 +152,86 @@ pub mod extensions { repo.fetch(D::from(id.clone()), session).await } + + impl<'a, T> ActivityExt for &'a T + where + T: ActivityExt, + { + type ActorId = T::ActorId; + type ObjectId = T::ObjectId; + + fn actor(&self) -> Option<::Output> { + T::actor(self) + } + + fn object(&self) -> Option<::Output> { + T::object(self) + } + } + + impl<'a, T> ActivityExt for &'a mut T + where + T: ActivityExt, + { + type ActorId = T::ActorId; + type ObjectId = T::ObjectId; + + fn actor(&self) -> Option<::Output> { + T::actor(self) + } + + fn object(&self) -> Option<::Output> { + T::object(self) + } + } + + impl ActivityExt for Box + where + T: ActivityExt, + { + type ActorId = T::ActorId; + type ObjectId = T::ObjectId; + + fn actor(&self) -> Option<::Output> { + T::actor(self) + } + + fn object(&self) -> Option<::Output> { + T::object(self) + } + } + + impl ActivityExt for Rc + where + T: ActivityExt, + { + type ActorId = T::ActorId; + type ObjectId = T::ObjectId; + + fn actor(&self) -> Option<::Output> { + T::actor(self) + } + + fn object(&self) -> Option<::Output> { + T::object(self) + } + } + + impl ActivityExt for Arc + where + T: ActivityExt, + { + type ActorId = T::ActorId; + type ObjectId = T::ObjectId; + + fn actor(&self) -> Option<::Output> { + T::actor(self) + } + + fn object(&self) -> Option<::Output> { + T::object(self) + } + } } impl<'a, T> PublicKey for &'a T