Building an ActivityStreams Library: 2026-07-27
Why another ActivityStreams library?
Prior to building activitystreams-vocabulary there was only one Rust crate for ActivityStreams 2.0 support: activitystreams-kinds.
That library provides the base vocabulary, and a rudimentary system for extending the vocabulary via serializable data structures.
There is also a basic trait system for tying into a more batteries-included framework for making ActivityPub requests.
I wanted something both more extensible on the data structure level, and less batteries-included on the networking level.
In order to achieve that, activitystreams-vocabulary makes heavy use of Rust’s declarative macros for reducing the boilerplate of vocabulary data strucutre creation. For example, extension protocols like ForgeFed define custom vocabulary that build on the base vocabulary types, including common fields and their related data structures. Macros like create_actor are useful for creating a Repository actor type that has all of the base fields of the Object type, actor-specific fields like inbox, outbox, and assertionMethod, and custom fields defined in the ForgeFed spec.
The macros also ensure consistency of implementation, handles field access boilerplate, and other quality-of-life methods for common use-cases.
What can users do with activitystreams-vocabulary?
All of the vocabulary types in ActivityStreams 2.0 are implemented, along with some security extension types. Future versions may include further extension types defined by FEP and/or W3C documents.
Beyond the core vocabulary types, a number of helper macros are also exported to help define custom types.
To use the macros without a pub use import for each use-site, use the #[macro_use] in the crate root:
#[macro_use]
extern crate activitystreams_vocabulary;
Users can also easily create their own interoperable vocabulary types by implementing the ActivityVocabulary trait. The impl_activity_vocabulary macro is especially helpful for creating custom vocabulary types.
For detailed instructions on library usage, and creating compatible extensions, see the main activitystreams-vocabulary documentation.
If you want to see a more real-world use-case, you can look at the activityforge crate that makes heavy use of activitystreams-vocabulary, and is the main motivation for its creation.
activitystreams-vocabulary aims for 100% documentation of its public API, and full test coverage. If you see a mistake, missing documentation, or have a feature you would like to see implemented, please submit an issue/PR on activitypub-rs/activitystreams-vocabulary.