#[cfg(feature = "url")]
use url::Url;
#[cfg(feature = "url")]
pub fn context() -> Url {
"https://www.w3.org/ns/activitystreams".parse().unwrap()
}
#[cfg(feature = "url")]
pub fn public() -> Url {
"https://www.w3.org/ns/activitystreams#Public"
.parse()
.unwrap()
}
#[cfg(feature = "url")]
pub fn security() -> Url {
"https://w3id.org/security/v1".parse().unwrap()
}
#[cfg(feature = "iri-string")]
pub fn context_iri() -> iri_string::types::IriString {
"https://www.w3.org/ns/activitystreams".parse().unwrap()
}
#[cfg(feature = "iri-string")]
pub fn public_iri() -> iri_string::types::IriString {
"https://www.w3.org/ns/activitystreams#Public"
.parse()
.unwrap()
}
#[cfg(feature = "iri-string")]
pub fn security_iri() -> iri_string::types::IriString {
"https://w3id.org/security/v1".parse().unwrap()
}
#[macro_export]
macro_rules! kind {
($x:ident, $y:ident) => {
#[derive(
Clone,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
serde::Deserialize,
serde::Serialize,
)]
pub enum $x {
$y,
}
impl std::fmt::Display for $x {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, stringify!($y))
}
}
impl Default for $x {
fn default() -> Self {
$x::$y
}
}
};
}
pub mod activity {
use crate::kind;
kind!(ActivityType, Activity);
kind!(AcceptType, Accept);
kind!(AddType, Add);
kind!(AnnounceType, Announce);
kind!(ArriveType, Arrive);
kind!(BlockType, Block);
kind!(CreateType, Create);
kind!(DeleteType, Delete);
kind!(DislikeType, Dislike);
kind!(FlagType, Flag);
kind!(FollowType, Follow);
kind!(IgnoreType, Ignore);
kind!(InviteType, Invite);
kind!(JoinType, Join);
kind!(LeaveType, Leave);
kind!(LikeType, Like);
kind!(ListenType, Listen);
kind!(MoveType, Move);
kind!(OfferType, Offer);
kind!(QuestionType, Question);
kind!(ReadType, Read);
kind!(RejectType, Reject);
kind!(RemoveType, Remove);
kind!(TentativeAcceptType, TentativeAccept);
kind!(TentativeRejectType, TentativeReject);
kind!(TravelType, Travel);
kind!(UndoType, Undo);
kind!(UpdateType, Update);
kind!(ViewType, View);
}
pub mod actor {
use crate::kind;
kind!(ApplicationType, Application);
kind!(GroupType, Group);
kind!(OrganizationType, Organization);
kind!(PersonType, Person);
kind!(ServiceType, Service);
}
pub mod collection {
use crate::kind;
kind!(CollectionType, Collection);
kind!(OrderedCollectionType, OrderedCollection);
kind!(CollectionPageType, CollectionPage);
kind!(OrderedCollectionPageType, OrderedCollectionPage);
}
pub mod link {
use crate::kind;
kind!(LinkType, Link);
kind!(MentionType, Mention);
}
pub mod object {
use crate::kind;
kind!(ObjectType, Object);
kind!(ArticleType, Article);
kind!(AudioType, Audio);
kind!(DocumentType, Document);
kind!(EventType, Event);
kind!(ImageType, Image);
kind!(NoteType, Note);
kind!(PageType, Page);
kind!(PlaceType, Place);
kind!(ProfileType, Profile);
kind!(RelationshipType, Relationship);
kind!(TombstoneType, Tombstone);
kind!(VideoType, Video);
}
#[cfg(test)]
mod tests {
use super::kind;
#[test]
fn to_string_works() {
kind!(MyType, My);
assert_eq!(MyType::My.to_string(), "My")
}
}