2024-04-06 19:16:15 +02:00
|
|
|
//! # apb
|
|
|
|
//! > traits and types for implementing [ActivityPub](https://www.w3.org/TR/activitypub/)
|
|
|
|
//!
|
|
|
|
//! The main type this crate exposes is the [Node], which can be:
|
|
|
|
//! - [Node::Empty]: not present in object
|
|
|
|
//! - [Node::Link]: contains just link to object
|
|
|
|
//! - [Node::Object]: contains embedded object
|
|
|
|
//! - [Node::Array]: contains array of embedded objects
|
|
|
|
//!
|
|
|
|
//! Nodes contain AP objects, which implement one or more traits (such as [Object] or [Actor])
|
|
|
|
//!
|
|
|
|
//! ## features
|
|
|
|
//! * `unstructured`: all traits are implemented for [serde_json::Value], so that it's possible to manipulate free-form json maps as valid AP objects
|
|
|
|
//! * `orm`: enum types are also database-friendly with sea-orm
|
|
|
|
//! * `fetch`: [Node] exposes [Node::fetch] to dereference remote nodes
|
|
|
|
//!
|
|
|
|
//! ## structure
|
|
|
|
//! - **[Base]** | **[BaseMut]** | [BaseType]
|
|
|
|
//! - [BaseType::Link] | **[Link]** | **[LinkMut]** | [LinkType]
|
|
|
|
//! - [LinkType::Mention]
|
|
|
|
//! - [LinkType::Link]
|
|
|
|
//! - [BaseType::Object] | **[Object]** | **[ObjectMut]** | [ObjectType]
|
|
|
|
//! - [ObjectType::Activity] | **[Activity]** | **[ActivityMut]** | [ActivityType]
|
|
|
|
//! - [ActivityType::Accept] | **[Accept]** | **[AcceptMut]** | [AcceptType]
|
|
|
|
//! - [AcceptType::TentativeAccept]
|
|
|
|
//! - [ActivityType::Add]
|
|
|
|
//! - [ActivityType::Announce]
|
|
|
|
//! - [ActivityType::Create]
|
|
|
|
//! - [ActivityType::Delete]
|
|
|
|
//! - [ActivityType::Dislike]
|
|
|
|
//! - [ActivityType::Flag]
|
|
|
|
//! - [ActivityType::Follow]
|
|
|
|
//! - [ActivityType::IntransitiveActivity] | **[IntransitiveActivity]** | **[IntransitiveActivityMut]** | [IntransitiveActivityType]
|
|
|
|
//! - [IntransitiveActivityType::IntransitiveActivity]
|
|
|
|
//! - [IntransitiveActivityType::Arrive]
|
|
|
|
//! - [IntransitiveActivityType::Question]
|
|
|
|
//! - [IntransitiveActivityType::Travel]
|
|
|
|
//! - [ActivityType::Ignore] | **[Ignore]** | **[IgnoreMut]** | [IgnoreType]
|
|
|
|
//! - [IgnoreType::Ignore]
|
|
|
|
//! - [IgnoreType::Block]
|
|
|
|
//! - [ActivityType::Join]
|
|
|
|
//! - [ActivityType::Leave]
|
|
|
|
//! - [ActivityType::Like]
|
|
|
|
//! - [ActivityType::Listen]
|
|
|
|
//! - [ActivityType::Move]
|
|
|
|
//! - [ActivityType::Offer] | **[Offer]** | **[OfferMut]** | [OfferType]
|
|
|
|
//! - [OfferType::Offer]
|
|
|
|
//! - [OfferType::Invite]
|
|
|
|
//! - [ActivityType::Read]
|
|
|
|
//! - [ActivityType::Reject] | **[Reject]** | **[RejectMut]** | [RejectType]
|
|
|
|
//! - [RejectType::Reject]
|
|
|
|
//! - [RejectType::TentativeReject]
|
|
|
|
//! - [ActivityType::Remove]
|
|
|
|
//! - [ActivityType::Undo]
|
|
|
|
//! - [ActivityType::Update]
|
|
|
|
//! - [ActivityType::View]
|
|
|
|
//! - [ObjectType::Actor] | **[Actor]** | **[ActorMut]** | [ActorType] *
|
|
|
|
//! - [ActorType::Application]
|
|
|
|
//! - [ActorType::Group]
|
|
|
|
//! - [ActorType::Organization]
|
|
|
|
//! - [ActorType::Person]
|
|
|
|
//! - [ObjectType::Article]
|
|
|
|
//! - [ObjectType::Collection] | **[Collection]** | **[CollectionMut]** | [CollectionType]
|
|
|
|
//! - [CollectionType::Collection]
|
|
|
|
//! - [CollectionType::CollectionPage]
|
|
|
|
//! - [CollectionType::OrderedCollection]
|
|
|
|
//! - [CollectionType::OrderedCollectionPage]
|
|
|
|
//! - [ObjectType::Document] | **[Document]** | **[DocumentMut]** | [DocumentType]
|
|
|
|
//! - [DocumentType::Document]
|
|
|
|
//! - [DocumentType::Audio]
|
|
|
|
//! - [DocumentType::Image]
|
|
|
|
//! - [DocumentType::Page]
|
|
|
|
//! - [DocumentType::Video]
|
|
|
|
//! - [ObjectType::Event]
|
|
|
|
//! - [ObjectType::Note]
|
|
|
|
//! - [ObjectType::Object]
|
|
|
|
//! - [ObjectType::Place]
|
|
|
|
//! - [ObjectType::Profile]
|
|
|
|
//! - [ObjectType::Relationship]
|
|
|
|
//! - [ObjectType::Tombstone]
|
|
|
|
//! - **[PublicKey]** | **[PublicKeyMut]** \*\*
|
|
|
|
//!
|
|
|
|
//! *: `Actor` is technically just an object, not really a "subtype"
|
|
|
|
//!
|
|
|
|
//! **: `PublicKey` is introduced in ActivityPub, it's not part of ActivityStream
|
|
|
|
//!
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-04-06 16:56:13 +02:00
|
|
|
mod macros;
|
2024-04-06 18:34:15 +02:00
|
|
|
pub(crate) use macros::{strenum, getter, setter};
|
2024-04-06 16:56:13 +02:00
|
|
|
|
|
|
|
mod node;
|
|
|
|
pub use node::Node;
|
|
|
|
|
2024-04-11 00:27:17 +02:00
|
|
|
pub mod server;
|
|
|
|
pub mod target;
|
2024-04-06 16:56:13 +02:00
|
|
|
|
2024-04-06 18:34:15 +02:00
|
|
|
mod key;
|
2024-04-06 16:56:13 +02:00
|
|
|
pub use key::{PublicKey, PublicKeyMut};
|
|
|
|
|
2024-04-11 00:27:17 +02:00
|
|
|
mod types;
|
|
|
|
pub use types::{
|
|
|
|
base::{Base, BaseMut, BaseType},
|
|
|
|
link::{Link, LinkMut, LinkType},
|
|
|
|
object::{
|
|
|
|
Object, ObjectMut, ObjectType,
|
|
|
|
activity::{
|
|
|
|
Activity, ActivityMut, ActivityType,
|
|
|
|
accept::{Accept, AcceptMut, AcceptType},
|
|
|
|
ignore::{Ignore, IgnoreMut, IgnoreType},
|
|
|
|
intransitive::{IntransitiveActivity, IntransitiveActivityMut, IntransitiveActivityType},
|
|
|
|
offer::{Offer, OfferMut, OfferType},
|
|
|
|
reject::{Reject, RejectMut, RejectType},
|
|
|
|
},
|
2024-05-15 17:14:51 +02:00
|
|
|
actor::{Actor, ActorMut, ActorType, Endpoints, EndpointsMut},
|
2024-04-11 00:27:17 +02:00
|
|
|
collection::{
|
|
|
|
Collection, CollectionMut, CollectionType,
|
|
|
|
page::{CollectionPage, CollectionPageMut}
|
|
|
|
},
|
|
|
|
document::{Document, DocumentMut, DocumentType},
|
|
|
|
place::{Place, PlaceMut},
|
2024-05-25 07:02:33 +02:00
|
|
|
profile::Profile,
|
2024-04-11 00:27:17 +02:00
|
|
|
relationship::{Relationship, RelationshipMut},
|
|
|
|
tombstone::{Tombstone, TombstoneMut},
|
2024-04-06 16:56:13 +02:00
|
|
|
},
|
|
|
|
};
|
2024-05-31 04:07:39 +02:00
|
|
|
|
|
|
|
#[cfg(feature = "unstructured")]
|
|
|
|
pub fn new() -> serde_json::Value {
|
|
|
|
serde_json::Value::Object(serde_json::Map::default())
|
|
|
|
}
|