astreams
: Types!
This commit is contained in:
parent
c1116d23e1
commit
260286a457
6 changed files with 759 additions and 105 deletions
|
@ -155,6 +155,29 @@ impl HasLinkedDataInterface for Node {
|
|||
Some(Ok(r#u64))
|
||||
}
|
||||
|
||||
fn ld_get_f32(&self, id: &str) -> ResultGetOne<f32> {
|
||||
let id = Id::from_string(id.to_string());
|
||||
|
||||
let property = self.properties.get_any(&id)?;
|
||||
|
||||
let value = match property.as_value() {
|
||||
None => return Some(Err(anyhow!("Couldn't process property as JSON-LD value"))),
|
||||
Some(value) => value,
|
||||
};
|
||||
|
||||
let number = match value.as_number() {
|
||||
None => return Some(Err(anyhow!("Couldn't process property as JSON-LD number"))),
|
||||
Some(number) => number
|
||||
};
|
||||
|
||||
let r#f32 = match number.as_f32_lossy() {
|
||||
None => return Some(Err(anyhow!("Couldn't losslessly convert JSON-LD number to u64"))),
|
||||
Some(r#f32) => r#f32,
|
||||
};
|
||||
|
||||
Some(Ok(f32))
|
||||
}
|
||||
|
||||
fn ld_get_timedelta(&self, id: &str) -> ResultGetOne<TimeDelta> {
|
||||
let id = Id::from_string(id.to_string());
|
||||
|
||||
|
@ -413,6 +436,26 @@ impl HasLinkedDataInterface for Node {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn ld_set_f32(&mut self, id: &str, value: f32) -> ResultSetOne {
|
||||
let id = Id::from_string(id.to_string());
|
||||
|
||||
let number = SynNumber::from(value);
|
||||
|
||||
let literal = Literal::Number(number);
|
||||
|
||||
let value = CoreValue::Literal(literal, None);
|
||||
|
||||
let object: Object = Object::Value(value);
|
||||
|
||||
let indexed_object: Indexed<Object> = Indexed::from(object);
|
||||
|
||||
let prop_objects: Multiset<Indexed<Object>> = Multiset::singleton(indexed_object);
|
||||
|
||||
self.properties.set(id, prop_objects);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn ld_set_timedelta(&mut self, id: &str, value: TimeDelta) -> ResultSetOne {
|
||||
let id = Id::from_string(id.to_string());
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
use chrono::{DateTime, Local, TimeDelta};
|
||||
use json_ld::syntax::LangTagBuf;
|
||||
use json_ld::syntax::{LangTagBuf, NumberBuf};
|
||||
use mediatype::MediaType;
|
||||
use anyhow::Result as AResult;
|
||||
use json_ld::Direction;
|
||||
use anyhow::{anyhow, Result as AResult};
|
||||
use json_ld::{Direction, Id, Indexed, Object, Value};
|
||||
use json_ld::object::Literal;
|
||||
use json_ld::object::node::Multiset;
|
||||
|
||||
mod jsonld;
|
||||
|
||||
|
@ -30,6 +32,7 @@ pub trait HasLinkedDataInterface: Sized {
|
|||
fn ld_get_langtag(&self, id: &str) -> ResultGetOne<LangTagBuf>;
|
||||
fn ld_get_u32(&self, id: &str) -> ResultGetOne<u32>;
|
||||
fn ld_get_u64(&self, id: &str) -> ResultGetOne<u64>;
|
||||
fn ld_get_f32(&self, id: &str) -> ResultGetOne<f32>;
|
||||
fn ld_get_timedelta(&self, id: &str) -> ResultGetOne<TimeDelta>;
|
||||
fn ld_get_datetime_local(&self, id: &str) -> ResultGetOne<DateTime<Local>>;
|
||||
fn ld_get_strings(&self, id: &str) -> ResultGetMany<String>;
|
||||
|
@ -41,6 +44,7 @@ pub trait HasLinkedDataInterface: Sized {
|
|||
fn ld_set_langtag(&mut self, id: &str, value: LangTagBuf) -> ResultSetOne;
|
||||
fn ld_set_u32(&mut self, id: &str, value: u32) -> ResultSetOne;
|
||||
fn ld_set_u64(&mut self, id: &str, value: u64) -> ResultSetOne;
|
||||
fn ld_set_f32(&mut self, id: &str, value: f32) -> ResultSetOne;
|
||||
fn ld_set_timedelta(&mut self, id: &str, value: TimeDelta) -> ResultSetOne;
|
||||
fn ld_set_datetime_local(&mut self, id: &str, value: DateTime<Local>) -> ResultSetOne;
|
||||
fn ld_set_strings(&mut self, id: &str, values: Vec<String>) -> ResultSetMany;
|
||||
|
|
|
@ -1,91 +0,0 @@
|
|||
//! Struct definitions for ActivityStreams Core and Extended Types.
|
||||
//!
|
||||
//! # Functional
|
||||
//!
|
||||
//! > Properties marked as being "Functional" can have only one value.
|
||||
//! >
|
||||
//! > Items not marked as "Functional" can have multiple values.
|
||||
//!
|
||||
//! # Specification
|
||||
//!
|
||||
//! - <https://www.w3.org/TR/activitystreams-vocabulary/>
|
||||
//!
|
||||
|
||||
use crate::vocab;
|
||||
use crate::linkeddata::LangString;
|
||||
use chrono::TimeDelta;
|
||||
|
||||
vocab!(
|
||||
"https://www.w3.org/ns/activitystreams#Object",
|
||||
ref ObjectRef,
|
||||
mut ObjectMut,
|
||||
one [
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#duration",
|
||||
-> TimeDelta,
|
||||
get_timedelta @ ld_get_timedelta,
|
||||
set_timedelta @ ld_set_timedelta,
|
||||
}
|
||||
],
|
||||
many [
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#name",
|
||||
-> LangString,
|
||||
get_name @ ld_get_langstrings,
|
||||
set_name @ ld_set_langstrings,
|
||||
}
|
||||
],
|
||||
child [
|
||||
|
||||
],
|
||||
children [
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#attachment",
|
||||
get_attachments,
|
||||
into_attachments_mut,
|
||||
set_attachments,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#attributedTo",
|
||||
get_attributed_to,
|
||||
into_attributed_to_mut,
|
||||
set_attributed_to,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#audience",
|
||||
get_audience,
|
||||
into_audience_mut,
|
||||
set_audience,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#content",
|
||||
get_content,
|
||||
into_content_mut,
|
||||
set_content,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#context",
|
||||
get_context,
|
||||
into_context_mut,
|
||||
set_context,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#bcc",
|
||||
get_bcc,
|
||||
into_bcc_mut,
|
||||
set_bcc,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#bto",
|
||||
get_bto,
|
||||
into_bto_mut,
|
||||
set_bto,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#cc",
|
||||
get_cc,
|
||||
into_cc_mut,
|
||||
set_cc,
|
||||
}
|
||||
],
|
||||
);
|
317
acrate_astreams/src/vocabulary/activitystreams_core.rs
Normal file
317
acrate_astreams/src/vocabulary/activitystreams_core.rs
Normal file
|
@ -0,0 +1,317 @@
|
|||
//! Struct definitions for ActivityStreams Core Types.
|
||||
//!
|
||||
//! # Specification
|
||||
//!
|
||||
//! - <https://www.w3.org/TR/activitystreams-vocabulary/>
|
||||
//!
|
||||
|
||||
use crate::vocab;
|
||||
use crate::linkeddata::LangString;
|
||||
use chrono::TimeDelta;
|
||||
use json_ld::syntax::LangTagBuf;
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Object",
|
||||
ref ObjectRef,
|
||||
mut ObjectMut,
|
||||
one [
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#duration",
|
||||
-> TimeDelta,
|
||||
get_timedelta @ ld_get_timedelta,
|
||||
set_timedelta @ ld_set_timedelta,
|
||||
}
|
||||
],
|
||||
many [
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#name",
|
||||
-> LangString,
|
||||
get_name @ ld_get_langstrings,
|
||||
set_name @ ld_set_langstrings,
|
||||
}
|
||||
],
|
||||
children [
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#attachment",
|
||||
get_attachments,
|
||||
into_attachments_mut,
|
||||
set_attachments,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#attributedTo",
|
||||
get_attributed_to,
|
||||
into_attributed_to_mut,
|
||||
set_attributed_to,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#audience",
|
||||
get_audiences,
|
||||
into_audiences_mut,
|
||||
set_audiences,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#content",
|
||||
get_content,
|
||||
into_content_mut,
|
||||
set_content,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#context",
|
||||
get_contexts,
|
||||
into_contexts_mut,
|
||||
set_contexts,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#bcc",
|
||||
get_bcc,
|
||||
into_bcc_mut,
|
||||
set_bcc,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#bto",
|
||||
get_bto,
|
||||
into_bto_mut,
|
||||
set_bto,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#cc",
|
||||
get_cc,
|
||||
into_cc_mut,
|
||||
set_cc,
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Link",
|
||||
ref LinkRef,
|
||||
mut LinkMut,
|
||||
one [
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#href",
|
||||
-> String,
|
||||
get_href @ ld_get_string,
|
||||
set_href @ ld_set_string,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#hreflang",
|
||||
-> LangTagBuf,
|
||||
get_hreflang @ ld_get_langtag,
|
||||
set_hreflang @ ld_set_langtag,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#height",
|
||||
-> u64,
|
||||
get_height @ ld_get_u64,
|
||||
set_height @ ld_set_u64,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#width",
|
||||
-> u64,
|
||||
get_width @ ld_get_u64,
|
||||
set_width @ ld_set_u64,
|
||||
}
|
||||
],
|
||||
many [
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#rel",
|
||||
-> String,
|
||||
get_rel @ ld_get_strings,
|
||||
set_rel @ ld_set_strings,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#name",
|
||||
-> LangString,
|
||||
get_name @ ld_get_langstrings,
|
||||
set_name @ ld_set_langstrings,
|
||||
}
|
||||
],
|
||||
child [
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#mediaType",
|
||||
get_media_type,
|
||||
into_media_type_mut,
|
||||
set_media_type,
|
||||
}
|
||||
],
|
||||
children [
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#preview",
|
||||
get_previews,
|
||||
into_previews_mut,
|
||||
set_previews,
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Activity",
|
||||
ref ActivityRef,
|
||||
mut ActivityMut,
|
||||
children [
|
||||
// TODO: This is an extension of attributedTo, how to represent that?
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#actor",
|
||||
get_actors,
|
||||
into_actors_mut,
|
||||
set_actors,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#object",
|
||||
get_objects,
|
||||
into_objects_mut,
|
||||
set_objects,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#target",
|
||||
get_targets,
|
||||
into_targets_mut,
|
||||
set_targets,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#result",
|
||||
get_results,
|
||||
into_results_mut,
|
||||
set_results,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#origin",
|
||||
get_origins,
|
||||
into_origins_mut,
|
||||
set_origins,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#object",
|
||||
get_instruments,
|
||||
into_instruments_mut,
|
||||
set_instruments,
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#IntransitiveActivity",
|
||||
ref IntransitiveActivityRef,
|
||||
mut IntransitiveActivityMut,
|
||||
children [
|
||||
// TODO: This is an extension of attributedTo, how to represent that?
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#actor",
|
||||
get_actors,
|
||||
into_actors_mut,
|
||||
set_actors,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#target",
|
||||
get_targets,
|
||||
into_targets_mut,
|
||||
set_targets,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#result",
|
||||
get_results,
|
||||
into_results_mut,
|
||||
set_results,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#origin",
|
||||
get_origins,
|
||||
into_origins_mut,
|
||||
set_origins,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#object",
|
||||
get_instruments,
|
||||
into_instruments_mut,
|
||||
set_instruments,
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Collection",
|
||||
ref CollectionRef,
|
||||
mut CollectionMut,
|
||||
one [
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#totalItems",
|
||||
-> u64,
|
||||
get_total_items @ ld_get_u64,
|
||||
set_total_items @ ld_set_u64,
|
||||
}
|
||||
],
|
||||
child [
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#current",
|
||||
get_current,
|
||||
into_current_mut,
|
||||
set_current,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#first",
|
||||
get_first,
|
||||
into_first_mut,
|
||||
set_first,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#last",
|
||||
get_last,
|
||||
into_last_mut,
|
||||
set_last,
|
||||
}
|
||||
],
|
||||
children [
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#items",
|
||||
get_items,
|
||||
into_items_mut,
|
||||
set_items,
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#OrderedCollection",
|
||||
ref OrderedCollectionRef,
|
||||
mut OrderedCollectionMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#CollectionPage",
|
||||
ref CollectionPageRef,
|
||||
mut CollectionPageMut,
|
||||
child [
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#partOf",
|
||||
get_part_of,
|
||||
into_part_of_mut,
|
||||
set_part_of,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#next",
|
||||
get_next,
|
||||
into_next_mut,
|
||||
set_next,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#prev",
|
||||
get_prev,
|
||||
into_prev_mut,
|
||||
set_prev,
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#OrderedCollectionPage",
|
||||
ref OrderedCollectionPageRef,
|
||||
mut OrderedCollectionPageMut,
|
||||
one [
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#startIndex",
|
||||
-> u64,
|
||||
get_start_index @ ld_get_u64,
|
||||
set_start_index @ ld_set_u64,
|
||||
}
|
||||
],
|
||||
}
|
380
acrate_astreams/src/vocabulary/activitystreams_extended.rs
Normal file
380
acrate_astreams/src/vocabulary/activitystreams_extended.rs
Normal file
|
@ -0,0 +1,380 @@
|
|||
//! Struct definitions for ActivityStreams Extended Types.
|
||||
//!
|
||||
//! # Specification
|
||||
//!
|
||||
//! - <https://www.w3.org/TR/activitystreams-vocabulary/>
|
||||
//!
|
||||
|
||||
use chrono::{DateTime, Local};
|
||||
use crate::vocab;
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Accept",
|
||||
ref AcceptRef,
|
||||
mut AcceptMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#TentativeAccept",
|
||||
ref TentativeAcceptRef,
|
||||
mut TentativeAcceptMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Add",
|
||||
ref AddRef,
|
||||
mut AddMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Arrive",
|
||||
ref ArriveRef,
|
||||
mut ArriveMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Create",
|
||||
ref CreateRef,
|
||||
mut CreateMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Delete",
|
||||
ref DeleteRef,
|
||||
mut DeleteMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Follow",
|
||||
ref FollowRef,
|
||||
mut FollowMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Ignore",
|
||||
ref IgnoreRef,
|
||||
mut IgnoreMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Join",
|
||||
ref JoinRef,
|
||||
mut JoinMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Leave",
|
||||
ref LeaveRef,
|
||||
mut LeaveMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Like",
|
||||
ref LikeRef,
|
||||
mut LikeMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Offer",
|
||||
ref OfferRef,
|
||||
mut OfferMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Invite",
|
||||
ref InviteRef,
|
||||
mut InviteMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Reject",
|
||||
ref RejectRef,
|
||||
mut RejectMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#TentativeReject",
|
||||
ref TentativeRejectRef,
|
||||
mut TentativeRejectMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Remove",
|
||||
ref RemoveRef,
|
||||
mut RemoveMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Undo",
|
||||
ref UndoRef,
|
||||
mut UndoMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Update",
|
||||
ref UpdateRef,
|
||||
mut UpdateMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#View",
|
||||
ref ViewRef,
|
||||
mut ViewMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Listen",
|
||||
ref ListenRef,
|
||||
mut ListenMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Read",
|
||||
ref ReadRef,
|
||||
mut ReadMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Move",
|
||||
ref MoveRef,
|
||||
mut MoveMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Travel",
|
||||
ref TravelRef,
|
||||
mut TravelMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Announce",
|
||||
ref AnnounceRef,
|
||||
mut AnnounceMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Block",
|
||||
ref BlockRef,
|
||||
mut BlockMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Flag",
|
||||
ref FlagRef,
|
||||
mut FlagMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Dislike",
|
||||
ref DislikeRef,
|
||||
mut DislikeMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Question",
|
||||
ref QuestionRef,
|
||||
mut QuestionMut,
|
||||
one [
|
||||
// TODO: Implement closed
|
||||
],
|
||||
children [
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#oneOf",
|
||||
get_one_ofs,
|
||||
into_one_ofs_mut,
|
||||
set_one_ofs,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#anyOf",
|
||||
get_any_ofs,
|
||||
into_any_ofs_mut,
|
||||
set_any_ofs,
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Application",
|
||||
ref ApplicationRef,
|
||||
mut ApplicationMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Group",
|
||||
ref GroupRef,
|
||||
mut GroupMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Organization",
|
||||
ref OrganizationRef,
|
||||
mut OrganizationMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Person",
|
||||
ref PersonRef,
|
||||
mut PersonMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Service",
|
||||
ref ServiceRef,
|
||||
mut ServiceMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Relationship",
|
||||
ref RelationshipRef,
|
||||
mut RelationshipMut,
|
||||
child [
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#subject",
|
||||
get_subject,
|
||||
into_subject_mut,
|
||||
set_subject,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#object",
|
||||
get_object,
|
||||
into_object_mut,
|
||||
set_object,
|
||||
}
|
||||
],
|
||||
children [
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#relationship",
|
||||
get_relationships,
|
||||
into_relationships_mut,
|
||||
set_relationships,
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Article",
|
||||
ref ArticleRef,
|
||||
mut ArticleMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Document",
|
||||
ref DocumentRef,
|
||||
mut DocumentMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Audio",
|
||||
ref AudioRef,
|
||||
mut AudioMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Image",
|
||||
ref ImageRef,
|
||||
mut ImageMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Video",
|
||||
ref VideoRef,
|
||||
mut VideoMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Note",
|
||||
ref NoteRef,
|
||||
mut NoteMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Page",
|
||||
ref PageRef,
|
||||
mut PageMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Event",
|
||||
ref EventRef,
|
||||
mut EventMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Place",
|
||||
ref PlaceRef,
|
||||
mut PlaceMut,
|
||||
one [
|
||||
// Percentage 0-100%
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#accuracy",
|
||||
-> f32,
|
||||
get_accuracy @ ld_get_f32,
|
||||
set_accuracy @ ld_set_f32,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#altitude",
|
||||
-> f32,
|
||||
get_altitude @ ld_get_f32,
|
||||
set_altitude @ ld_set_f32,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#latitude",
|
||||
-> f32,
|
||||
get_latitude @ ld_get_f32,
|
||||
set_latitude @ ld_set_f32,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#longitude",
|
||||
-> f32,
|
||||
get_longitude @ ld_get_f32,
|
||||
set_longitude @ ld_set_f32,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#radius",
|
||||
-> f32,
|
||||
get_radius @ ld_get_f32,
|
||||
set_radius @ ld_set_f32,
|
||||
},
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#units",
|
||||
-> String,
|
||||
get_unit @ ld_get_string,
|
||||
set_unit @ ld_set_string,
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Mention",
|
||||
ref MentionRef,
|
||||
mut MentionMut,
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Profile",
|
||||
ref ProfileRef,
|
||||
mut ProfileMut,
|
||||
child [
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#describes",
|
||||
get_describes,
|
||||
into_describes_mut,
|
||||
set_describes,
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
vocab! {
|
||||
"https://www.w3.org/ns/activitystreams#Tombstone",
|
||||
ref TombstoneRef,
|
||||
mut TombstoneMut,
|
||||
// TODO: formerType is badly defined?
|
||||
one [
|
||||
{
|
||||
"https://www.w3.org/ns/activitystreams#deleted",
|
||||
-> DateTime<Local>,
|
||||
get_deleted @ ld_get_datetimelocal,
|
||||
set_deleted @ ld_set_datetimelocal,
|
||||
}
|
||||
],
|
||||
}
|
|
@ -1,12 +1,13 @@
|
|||
pub mod activitystreams;
|
||||
pub mod activitystreams_core;
|
||||
pub mod mastodon;
|
||||
pub mod miajetzt;
|
||||
pub mod litepub;
|
||||
pub mod lemmy;
|
||||
mod activitystreams_extended;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! vocab {
|
||||
(
|
||||
{
|
||||
$vocab_iri:literal,
|
||||
|
||||
$( #[ $vocab_ref_meta:meta ] )*
|
||||
|
@ -25,7 +26,7 @@ macro_rules! vocab {
|
|||
|
||||
$( #[ $one_get_meta:meta ] )*
|
||||
$one_get_name:ident @ $one_get_via:ident,
|
||||
|
||||
|
||||
$( #[ $one_set_meta:meta ] )*
|
||||
$one_set_name:ident @ $one_set_via:ident,
|
||||
}
|
||||
|
@ -43,14 +44,14 @@ macro_rules! vocab {
|
|||
|
||||
$( #[ $many_get_meta:meta ] )*
|
||||
$many_get_name:ident @ $many_get_via:ident,
|
||||
|
||||
|
||||
$( #[ $many_set_meta:meta ] )*
|
||||
$many_set_name:ident @ $many_set_via:ident,
|
||||
}
|
||||
),*
|
||||
],
|
||||
)?
|
||||
|
||||
|
||||
$(
|
||||
child [
|
||||
$(
|
||||
|
@ -62,15 +63,15 @@ macro_rules! vocab {
|
|||
|
||||
$( #[ $child_into_meta:meta ] )*
|
||||
$child_into_name:ident,
|
||||
|
||||
|
||||
$( #[ $child_set_meta:meta ] )*
|
||||
$child_set_name:ident,
|
||||
}
|
||||
),*
|
||||
|
||||
|
||||
],
|
||||
)?
|
||||
|
||||
|
||||
$(
|
||||
children [
|
||||
$(
|
||||
|
@ -82,15 +83,15 @@ macro_rules! vocab {
|
|||
|
||||
$( #[ $children_into_meta:meta ] )*
|
||||
$children_into_name:ident,
|
||||
|
||||
|
||||
$( #[ $children_set_meta:meta ] )*
|
||||
$children_set_name:ident,
|
||||
}
|
||||
),*
|
||||
|
||||
|
||||
],
|
||||
)?
|
||||
) => {
|
||||
} => {
|
||||
$( #[ $vocab_ref_meta ] )*
|
||||
#[repr(transparent)]
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
Loading…
Add table
Reference in a new issue