Implement activitypub traits for borrows & pointers

This commit is contained in:
Aode (lion) 2021-11-28 14:15:04 -06:00
parent 9376ecb971
commit 144d0ad0c2

View file

@ -1,5 +1,7 @@
//! Traits desccribing basic activitystreams types
use std::{rc::Rc, sync::Arc};
use url::Url;
/// A type that represents a Public Key
@ -91,3 +93,448 @@ pub fn delivery_inbox<'a>(actor: &'a impl Actor, obj: &impl DeliverableObject) -
actor.inbox()
}
}
impl<'a, T> PublicKey for &'a T
where
T: PublicKey,
{
fn id(&self) -> &Url {
T::id(self)
}
fn owner(&self) -> &Url {
T::owner(self)
}
fn public_key_pem(&self) -> &str {
T::public_key_pem(self)
}
}
impl<'a, T> PublicKey for &'a mut T
where
T: PublicKey,
{
fn id(&self) -> &Url {
T::id(self)
}
fn owner(&self) -> &Url {
T::owner(self)
}
fn public_key_pem(&self) -> &str {
T::public_key_pem(self)
}
}
impl<T> PublicKey for Box<T>
where
T: PublicKey,
{
fn id(&self) -> &Url {
T::id(self)
}
fn owner(&self) -> &Url {
T::owner(self)
}
fn public_key_pem(&self) -> &str {
T::public_key_pem(self)
}
}
impl<T> PublicKey for Rc<T>
where
T: PublicKey,
{
fn id(&self) -> &Url {
T::id(self)
}
fn owner(&self) -> &Url {
T::owner(self)
}
fn public_key_pem(&self) -> &str {
T::public_key_pem(self)
}
}
impl<T> PublicKey for Arc<T>
where
T: PublicKey,
{
fn id(&self) -> &Url {
T::id(self)
}
fn owner(&self) -> &Url {
T::owner(self)
}
fn public_key_pem(&self) -> &str {
T::public_key_pem(self)
}
}
impl<'a, T> Object for &'a T
where
T: Object,
{
type Kind = T::Kind;
fn id(&self) -> &Url {
T::id(self)
}
fn kind(&self) -> &Self::Kind {
T::kind(self)
}
}
impl<'a, T> Object for &'a mut T
where
T: Object,
{
type Kind = T::Kind;
fn id(&self) -> &Url {
T::id(self)
}
fn kind(&self) -> &Self::Kind {
T::kind(self)
}
}
impl<T> Object for Box<T>
where
T: Object,
{
type Kind = T::Kind;
fn id(&self) -> &Url {
T::id(self)
}
fn kind(&self) -> &Self::Kind {
T::kind(self)
}
}
impl<T> Object for Rc<T>
where
T: Object,
{
type Kind = T::Kind;
fn id(&self) -> &Url {
T::id(self)
}
fn kind(&self) -> &Self::Kind {
T::kind(self)
}
}
impl<T> Object for Arc<T>
where
T: Object,
{
type Kind = T::Kind;
fn id(&self) -> &Url {
T::id(self)
}
fn kind(&self) -> &Self::Kind {
T::kind(self)
}
}
impl<'a, T> DeliverableObject for &'a T
where
T: DeliverableObject,
{
fn to(&self) -> &[Url] {
T::to(self)
}
fn cc(&self) -> &[Url] {
T::cc(self)
}
}
impl<'a, T> DeliverableObject for &'a mut T
where
T: DeliverableObject,
{
fn to(&self) -> &[Url] {
T::to(self)
}
fn cc(&self) -> &[Url] {
T::cc(self)
}
}
impl<T> DeliverableObject for Box<T>
where
T: DeliverableObject,
{
fn to(&self) -> &[Url] {
T::to(self)
}
fn cc(&self) -> &[Url] {
T::cc(self)
}
}
impl<T> DeliverableObject for Rc<T>
where
T: DeliverableObject,
{
fn to(&self) -> &[Url] {
T::to(self)
}
fn cc(&self) -> &[Url] {
T::cc(self)
}
}
impl<T> DeliverableObject for Arc<T>
where
T: DeliverableObject,
{
fn to(&self) -> &[Url] {
T::to(self)
}
fn cc(&self) -> &[Url] {
T::cc(self)
}
}
impl<'a, T> Activity for &'a T
where
T: Activity,
{
fn actor_id(&self) -> &Url {
T::actor_id(self)
}
fn object_id(&self) -> &Url {
T::object_id(self)
}
}
impl<'a, T> Activity for &'a mut T
where
T: Activity,
{
fn actor_id(&self) -> &Url {
T::actor_id(self)
}
fn object_id(&self) -> &Url {
T::object_id(self)
}
}
impl<T> Activity for Box<T>
where
T: Activity,
{
fn actor_id(&self) -> &Url {
T::actor_id(self)
}
fn object_id(&self) -> &Url {
T::object_id(self)
}
}
impl<T> Activity for Rc<T>
where
T: Activity,
{
fn actor_id(&self) -> &Url {
T::actor_id(self)
}
fn object_id(&self) -> &Url {
T::object_id(self)
}
}
impl<T> Activity for Arc<T>
where
T: Activity,
{
fn actor_id(&self) -> &Url {
T::actor_id(self)
}
fn object_id(&self) -> &Url {
T::object_id(self)
}
}
impl<'a, T> Actor for &'a T
where
T: Actor,
{
type PublicKey = T::PublicKey;
fn inbox(&self) -> &Url {
T::inbox(self)
}
fn outbox(&self) -> &Url {
T::outbox(self)
}
fn preferred_username(&self) -> &str {
T::preferred_username(self)
}
fn public_key(&self) -> &Self::PublicKey {
T::public_key(self)
}
fn name(&self) -> Option<&str> {
T::name(self)
}
fn shared_inbox(&self) -> Option<&Url> {
T::shared_inbox(self)
}
}
impl<'a, T> Actor for &'a mut T
where
T: Actor,
{
type PublicKey = T::PublicKey;
fn inbox(&self) -> &Url {
T::inbox(self)
}
fn outbox(&self) -> &Url {
T::outbox(self)
}
fn preferred_username(&self) -> &str {
T::preferred_username(self)
}
fn public_key(&self) -> &Self::PublicKey {
T::public_key(self)
}
fn name(&self) -> Option<&str> {
T::name(self)
}
fn shared_inbox(&self) -> Option<&Url> {
T::shared_inbox(self)
}
}
impl<T> Actor for Box<T>
where
T: Actor,
{
type PublicKey = T::PublicKey;
fn inbox(&self) -> &Url {
T::inbox(self)
}
fn outbox(&self) -> &Url {
T::outbox(self)
}
fn preferred_username(&self) -> &str {
T::preferred_username(self)
}
fn public_key(&self) -> &Self::PublicKey {
T::public_key(self)
}
fn name(&self) -> Option<&str> {
T::name(self)
}
fn shared_inbox(&self) -> Option<&Url> {
T::shared_inbox(self)
}
}
impl<T> Actor for Rc<T>
where
T: Actor,
{
type PublicKey = T::PublicKey;
fn inbox(&self) -> &Url {
T::inbox(self)
}
fn outbox(&self) -> &Url {
T::outbox(self)
}
fn preferred_username(&self) -> &str {
T::preferred_username(self)
}
fn public_key(&self) -> &Self::PublicKey {
T::public_key(self)
}
fn name(&self) -> Option<&str> {
T::name(self)
}
fn shared_inbox(&self) -> Option<&Url> {
T::shared_inbox(self)
}
}
impl<T> Actor for Arc<T>
where
T: Actor,
{
type PublicKey = T::PublicKey;
fn inbox(&self) -> &Url {
T::inbox(self)
}
fn outbox(&self) -> &Url {
T::outbox(self)
}
fn preferred_username(&self) -> &str {
T::preferred_username(self)
}
fn public_key(&self) -> &Self::PublicKey {
T::public_key(self)
}
fn name(&self) -> Option<&str> {
T::name(self)
}
fn shared_inbox(&self) -> Option<&Url> {
T::shared_inbox(self)
}
}