impl ActivityExt for borrows, pointers
This commit is contained in:
parent
daa12de4a8
commit
9f4f7154cb
|
@ -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<<Self::ActorId as Dereference>::Output> {
|
||||
T::actor(self)
|
||||
}
|
||||
|
||||
fn object(&self) -> Option<<Self::ObjectId as Dereference>::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<<Self::ActorId as Dereference>::Output> {
|
||||
T::actor(self)
|
||||
}
|
||||
|
||||
fn object(&self) -> Option<<Self::ObjectId as Dereference>::Output> {
|
||||
T::object(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> ActivityExt for Box<T>
|
||||
where
|
||||
T: ActivityExt,
|
||||
{
|
||||
type ActorId = T::ActorId;
|
||||
type ObjectId = T::ObjectId;
|
||||
|
||||
fn actor(&self) -> Option<<Self::ActorId as Dereference>::Output> {
|
||||
T::actor(self)
|
||||
}
|
||||
|
||||
fn object(&self) -> Option<<Self::ObjectId as Dereference>::Output> {
|
||||
T::object(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> ActivityExt for Rc<T>
|
||||
where
|
||||
T: ActivityExt,
|
||||
{
|
||||
type ActorId = T::ActorId;
|
||||
type ObjectId = T::ObjectId;
|
||||
|
||||
fn actor(&self) -> Option<<Self::ActorId as Dereference>::Output> {
|
||||
T::actor(self)
|
||||
}
|
||||
|
||||
fn object(&self) -> Option<<Self::ObjectId as Dereference>::Output> {
|
||||
T::object(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> ActivityExt for Arc<T>
|
||||
where
|
||||
T: ActivityExt,
|
||||
{
|
||||
type ActorId = T::ActorId;
|
||||
type ObjectId = T::ObjectId;
|
||||
|
||||
fn actor(&self) -> Option<<Self::ActorId as Dereference>::Output> {
|
||||
T::actor(self)
|
||||
}
|
||||
|
||||
fn object(&self) -> Option<<Self::ObjectId as Dereference>::Output> {
|
||||
T::object(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T> PublicKey for &'a T
|
||||
|
|
Loading…
Reference in a new issue