apb/
lib.rs

1//! # apb
2//! > traits and types for implementing [ActivityPub](https://www.w3.org/TR/activitypub/)
3//!
4//! The main type this crate exposes is the [Node], which can be:
5//!  - [Node::Empty]: not present in object
6//!  - [Node::Link]: contains just link to object
7//!  - [Node::Object]: contains embedded object
8//!  - [Node::Array]: contains array of embedded objects
9//!
10//! Nodes contain AP objects, which implement one or more traits (such as [Object] or [Actor])
11//!
12//! ## features
13//! * `unstructured`: all traits are implemented for [serde_json::Value], so that it's possible to manipulate free-form json maps as valid AP objects
14//! * `orm`: enum types are also database-friendly with sea-orm
15//! * `fetch`: [Node] exposes [Node::fetch] to dereference remote nodes
16//!
17//! ## structure
18//! - **[Base]** | **[BaseMut]** | [BaseType]
19//!   - [BaseType::Link] | **[Link]** | **[LinkMut]** | [LinkType]
20//!     - [LinkType::Mention]
21//!     - [LinkType::Link]
22//!   - [BaseType::Object] | **[Object]** | **[ObjectMut]** | [ObjectType]
23//!     - [ObjectType::Activity] | **[Activity]** | **[ActivityMut]** | [ActivityType]
24//!       - [ActivityType::Accept] | **[Accept]** | **[AcceptMut]** | [AcceptType]
25//!         - [AcceptType::TentativeAccept]
26//!       - [ActivityType::Add]
27//!       - [ActivityType::Announce]
28//!       - [ActivityType::Create]
29//!       - [ActivityType::Delete]
30//!       - [ActivityType::Dislike]
31//!       - [ActivityType::Flag]
32//!       - [ActivityType::Follow]
33//!       - [ActivityType::IntransitiveActivity] | **[IntransitiveActivity]** | **[IntransitiveActivityMut]** | [IntransitiveActivityType]
34//!         - [IntransitiveActivityType::IntransitiveActivity]
35//!         - [IntransitiveActivityType::Arrive]
36//!         - [IntransitiveActivityType::Question]
37//!         - [IntransitiveActivityType::Travel]
38//!       - [ActivityType::Ignore] | **[Ignore]** | **[IgnoreMut]** | [IgnoreType]
39//!         - [IgnoreType::Ignore]
40//!         - [IgnoreType::Block]
41//!       - [ActivityType::Join]
42//!       - [ActivityType::Leave]
43//!       - [ActivityType::Like]
44//!       - [ActivityType::Listen]
45//!       - [ActivityType::Move]
46//!       - [ActivityType::Offer] | **[Offer]** | **[OfferMut]** | [OfferType]
47//!           - [OfferType::Offer]
48//!           - [OfferType::Invite]
49//!       - [ActivityType::Read]
50//!       - [ActivityType::Reject] | **[Reject]** | **[RejectMut]** | [RejectType]
51//!           - [RejectType::Reject]
52//!           - [RejectType::TentativeReject]
53//!       - [ActivityType::Remove]
54//!       - [ActivityType::Undo]
55//!       - [ActivityType::Update]
56//!       - [ActivityType::View]
57//!     - [ObjectType::Actor] | **[Actor]** | **[ActorMut]** | [ActorType] *
58//!       - [ActorType::Application]
59//!       - [ActorType::Group]
60//!       - [ActorType::Organization]
61//!       - [ActorType::Person]
62//!     - [ObjectType::Article]
63//!     - [ObjectType::Collection] | **[Collection]** | **[CollectionMut]** | [CollectionType]
64//!       - [CollectionType::Collection]
65//!       - [CollectionType::CollectionPage]
66//!       - [CollectionType::OrderedCollection]
67//!       - [CollectionType::OrderedCollectionPage]
68//!     - [ObjectType::Document] | **[Document]** | **[DocumentMut]** | [DocumentType]
69//!       - [DocumentType::Document]
70//!       - [DocumentType::Audio]
71//!       - [DocumentType::Image]
72//!       - [DocumentType::Page]
73//!       - [DocumentType::Video]
74//!     - [ObjectType::Event]
75//!     - [ObjectType::Note]
76//!     - [ObjectType::Object]
77//!     - [ObjectType::Place]
78//!     - [ObjectType::Profile]
79//!     - [ObjectType::Relationship]
80//!     - [ObjectType::Tombstone]
81//!   - **[PublicKey]** | **[PublicKeyMut]** \*\*
82//!
83//! *: `Actor` is technically just an object, not really a "subtype"
84//!
85//! **: `PublicKey` is introduced in ActivityPub, it's not part of ActivityStream
86//!
87
88
89
90mod macros;
91pub(crate) use macros::strenum;
92
93#[cfg(feature = "unstructured")]
94pub(crate) use macros::{getter, setter};
95
96mod node;
97pub use node::Node;
98
99pub mod target;
100
101mod key;
102pub use key::{PublicKey, PublicKeyMut};
103
104pub mod field;
105pub use field::{Field, FieldErr};
106
107#[cfg(feature = "shortcuts")]
108pub mod shortcuts;
109#[cfg(feature = "shortcuts")]
110pub use shortcuts::Shortcuts;
111
112#[cfg(feature = "jsonld")]
113pub mod jsonld;
114
115#[cfg(feature = "jsonld")]
116pub use jsonld::LD;
117
118mod types;
119pub use types::{
120	base::{Base, BaseMut, BaseType},
121	link::{Link, LinkMut, LinkType},
122	object::{
123		Object, ObjectMut, ObjectType,
124		activity::{
125			Activity, ActivityMut, ActivityType,
126			accept::{Accept, AcceptMut, AcceptType},
127			ignore::{Ignore, IgnoreMut, IgnoreType},
128			intransitive::{IntransitiveActivity, IntransitiveActivityMut, IntransitiveActivityType},
129			offer::{Offer, OfferMut, OfferType},
130			reject::{Reject, RejectMut, RejectType},
131		},
132		actor::{Actor, ActorMut, ActorType, Endpoints, EndpointsMut},
133		collection::{
134			Collection, CollectionMut, CollectionType,
135			page::{CollectionPage, CollectionPageMut}
136		},
137		document::{Document, DocumentMut, DocumentType},
138		place::{Place, PlaceMut},
139		profile::Profile,
140		relationship::{Relationship, RelationshipMut},
141		tombstone::{Tombstone, TombstoneMut},
142	},
143};
144
145#[cfg(feature = "unstructured")]
146pub fn new() -> serde_json::Value {
147	serde_json::Value::Object(serde_json::Map::default())
148}
149
150#[cfg(feature = "fetch")]
151pub use reqwest;