Add URL functions to kinds lib

This commit is contained in:
Aode (lion) 2021-11-19 08:53:46 -06:00
parent 8f5badad06
commit dff8fbbe59
2 changed files with 20 additions and 0 deletions

View file

@ -13,6 +13,7 @@ edition = "2021"
[dependencies]
serde = { version = "1", features = ["derive"] }
url = "2"
[dev-dependencies]
anyhow = "1"

View file

@ -2,6 +2,25 @@
//!
//! Enums representing typed versions of activitypub 'type' fields.
use url::Url;
/// Returns the `https://www.w3.org/ns/activitystreams` Url
pub fn context() -> Url {
"https://www.w3.org/ns/activitystreams".parse().unwrap()
}
/// Returns the `https://www.w3.org/ns/activitystreams#Public` Url
pub fn public() -> Url {
"https://www.w3.org/ns/activitystreams#Public"
.parse()
.unwrap()
}
/// Returns the `https://w3id.org/security/v1` Url
pub fn security() -> Url {
"https://w3id.org/security/v1".parse().unwrap()
}
/// Generate an enum implementing serde's Serialize and Deserialize with a single variant
///
/// This is useful for describing constants