mirror of
https://git.asonix.dog/asonix/activitystreams.git
synced 2024-11-22 03:40:59 +00:00
Bring in new properties derive
This commit is contained in:
parent
d738c5e8fa
commit
62c8d245ff
13 changed files with 1361 additions and 998 deletions
|
@ -10,7 +10,7 @@ keywords = ["activitystreams", "activitypub"]
|
|||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
activitystreams-traits = { version = "0.2", path = "activitystreams-traits" }
|
||||
activitystreams-traits = { version = "0.3", path = "activitystreams-traits" }
|
||||
activitystreams-types = { version = "0.3.0", path = "activitystreams-types" }
|
||||
|
||||
[dev-dependencies]
|
||||
|
@ -18,7 +18,7 @@ anyhow = "1.0"
|
|||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
serde_json = "1.0"
|
||||
activitystreams-derive = { version = "0.2", path = "activitystreams-derive" }
|
||||
activitystreams-derive = { version = "0.3", path = "activitystreams-derive" }
|
||||
|
||||
[workspace]
|
||||
members = [
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "activitystreams-derive"
|
||||
description = "Derive macros for activitystreams"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
license = "GPL-3.0"
|
||||
authors = ["asonix <asonix.dev@gmail.com>"]
|
||||
repository = "https://git.asonix.dog/Aardwolf/activitystreams"
|
||||
|
@ -15,7 +15,7 @@ syn = "1.0"
|
|||
proc-macro2 = "1.0"
|
||||
|
||||
[dev-dependencies]
|
||||
activitystreams-traits = { version = "0.2", path = "../activitystreams-traits" }
|
||||
activitystreams-traits = { version = "0.3", path = "../activitystreams-traits" }
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
serde_json = "1.0"
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "activitystreams-traits"
|
||||
description = "Traits for ActivityStreams objects"
|
||||
version = "0.2.0"
|
||||
description = "Traits for ActivityStreams 2.0 objects"
|
||||
version = "0.3.0"
|
||||
license = "GPL-3.0"
|
||||
authors = ["asonix <asonix.dev@gmail.com>"]
|
||||
repository = "https://git.asonix.dog/Aardwolf/activitystreams"
|
||||
|
@ -10,9 +10,8 @@ keywords = ["activitystreams", "activitypub"]
|
|||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
serde = "1.0"
|
||||
serde_json = "1.0"
|
||||
thiserror = "1.0"
|
||||
typetag = "0.1.4"
|
||||
|
||||
[dev-dependencies]
|
||||
serde_derive = "1.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* This file is part of ActivityStreams Traits.
|
||||
*
|
||||
* Copyright © 2018 Riley Trautman
|
||||
*
|
||||
* ActivityStreams Traits is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ActivityStreams Traits is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with ActivityStreams Traits. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use std::result;
|
||||
|
||||
/// The Error type
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, thiserror::Error)]
|
||||
pub enum Error {
|
||||
/// This error occurs when an Activity Streams type does not contain a requested value
|
||||
#[error("Key not present")]
|
||||
NotFound,
|
||||
|
||||
/// This error occurs when a requested value could not be deserialized into the requested type
|
||||
#[error("Failed to deserialize data as requested type")]
|
||||
Deserialize,
|
||||
|
||||
/// This error occurs when a provided item could not be serialized into an Activity Streams
|
||||
/// type
|
||||
#[error("Failed to serialize data")]
|
||||
Serialize,
|
||||
}
|
||||
|
||||
/// An alias for Result<T, Error>
|
||||
pub type Result<T> = result::Result<T, Error>;
|
|
@ -26,7 +26,7 @@
|
|||
//!
|
||||
//! ```rust
|
||||
//! use activitystreams_traits::{Object, Actor};
|
||||
//! use serde_derive::{Deserialize, Serialize};
|
||||
//! use serde::{Deserialize, Serialize};
|
||||
//!
|
||||
//! #[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
//! #[serde(rename_all = "camelCase")]
|
||||
|
@ -38,7 +38,9 @@
|
|||
//! kind: String,
|
||||
//! }
|
||||
//!
|
||||
//! #[typetag::serde]
|
||||
//! impl Object for Persona {}
|
||||
//! #[typetag::serde]
|
||||
//! impl Actor for Persona {}
|
||||
//!
|
||||
//! # fn main() {}
|
||||
|
@ -47,14 +49,13 @@
|
|||
mod activity;
|
||||
mod actor;
|
||||
mod collection;
|
||||
mod error;
|
||||
mod link;
|
||||
mod object;
|
||||
pub mod properties;
|
||||
|
||||
pub use self::activity::*;
|
||||
pub use self::actor::*;
|
||||
pub use self::collection::*;
|
||||
pub use self::error::*;
|
||||
pub use self::link::*;
|
||||
pub use self::object::*;
|
||||
pub use self::{
|
||||
activity::{Activity, IntransitiveActivity},
|
||||
actor::Actor,
|
||||
collection::{Collection, CollectionPage},
|
||||
link::Link,
|
||||
object::Object,
|
||||
};
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* along with ActivityStreams Traits. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use serde::{de::DeserializeOwned, ser::Serialize};
|
||||
use std::any::Any;
|
||||
|
||||
/// A Link is an indirect, qualified reference to a resource identified by a URL.
|
||||
///
|
||||
|
@ -27,4 +27,9 @@ use serde::{de::DeserializeOwned, ser::Serialize};
|
|||
/// used, it establishes a qualified relation connecting the subject (the containing object) to the
|
||||
/// resource identified by the href. Properties of the Link are properties of the reference as
|
||||
/// opposed to properties of the resource.
|
||||
pub trait Link: DeserializeOwned + Serialize {}
|
||||
#[typetag::serde(tag = "type")]
|
||||
pub trait Link: std::fmt::Debug {
|
||||
fn as_any(&self) -> &dyn Any;
|
||||
|
||||
fn as_any_mut(&mut self) -> &mut dyn Any;
|
||||
}
|
||||
|
|
|
@ -17,11 +17,16 @@
|
|||
* along with ActivityStreams Traits. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use serde::{de::DeserializeOwned, ser::Serialize};
|
||||
use std::any::Any;
|
||||
|
||||
/// Describes an object of any kind.
|
||||
///
|
||||
/// The Object type serves as the base type for most of the other kinds of objects defined in the
|
||||
/// Activity Vocabulary, including other Core types such as `Activity`, `IntransitiveActivity`,
|
||||
/// `Collection` and `OrderedCollection`.
|
||||
pub trait Object: DeserializeOwned + Serialize {}
|
||||
#[typetag::serde(tag = "type")]
|
||||
pub trait Object: std::fmt::Debug {
|
||||
fn as_any(&self) -> &dyn Any;
|
||||
|
||||
fn as_any_mut(&mut self) -> &mut dyn Any;
|
||||
}
|
||||
|
|
|
@ -1,89 +0,0 @@
|
|||
/*
|
||||
* This file is part of ActivityStreams Traits.
|
||||
*
|
||||
* Copyright © 2018 Riley Trautman
|
||||
*
|
||||
* ActivityStreams Traits is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ActivityStreams Traits is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with ActivityStreams Traits. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//! A module containing helpers for tranlsating common JSON representations to and from concrete
|
||||
//! types
|
||||
|
||||
use serde::{de::DeserializeOwned, ser::Serialize};
|
||||
|
||||
use crate::error::{Error, Result};
|
||||
|
||||
/// Deserialize a `Value` into concrete type I
|
||||
pub fn from_value<I>(item: &serde_json::Value) -> Result<I>
|
||||
where
|
||||
I: DeserializeOwned,
|
||||
{
|
||||
serde_json::from_value(item.clone()).map_err(|_| Error::Deserialize)
|
||||
}
|
||||
|
||||
/// Serialize concrete type I into a `Value`
|
||||
pub fn to_value<I>(item: I) -> Result<serde_json::Value>
|
||||
where
|
||||
I: Serialize,
|
||||
{
|
||||
serde_json::to_value(item).map_err(|_| Error::Serialize)
|
||||
}
|
||||
|
||||
/// Deserialize an `Option<Value>` into concrete type I
|
||||
pub fn from_item<I>(item: &Option<serde_json::Value>) -> Result<I>
|
||||
where
|
||||
I: DeserializeOwned,
|
||||
{
|
||||
if let &Some(ref item) = item {
|
||||
from_value(item)
|
||||
} else {
|
||||
Err(Error::NotFound)
|
||||
}
|
||||
}
|
||||
|
||||
/// Serialize concrete type I into an `Option<Value>`
|
||||
pub fn to_item<I>(item: I) -> Result<Option<serde_json::Value>>
|
||||
where
|
||||
I: Serialize,
|
||||
{
|
||||
to_value(item).map(Some)
|
||||
}
|
||||
|
||||
/// Deserialize a `Vec<Value>` into a `Vec<I>`
|
||||
pub fn from_vec<I>(v: &Vec<serde_json::Value>) -> Result<Vec<I>>
|
||||
where
|
||||
I: DeserializeOwned,
|
||||
{
|
||||
v.iter().fold(Ok(Vec::new()), |acc, item| match acc {
|
||||
Ok(mut acc) => from_value(item).map(|item| {
|
||||
acc.push(item);
|
||||
acc
|
||||
}),
|
||||
e => e,
|
||||
})
|
||||
}
|
||||
|
||||
/// Serialize a `Vec<I>` into a `Vec<Value>`
|
||||
pub fn to_vec<I>(v: Vec<I>) -> Result<Vec<serde_json::Value>>
|
||||
where
|
||||
I: Serialize,
|
||||
{
|
||||
v.into_iter().fold(Ok(Vec::new()), |acc, item| match acc {
|
||||
Ok(mut acc) => to_value(item).map(|item| {
|
||||
acc.push(item);
|
||||
acc
|
||||
}),
|
||||
e => e,
|
||||
})
|
||||
}
|
|
@ -11,13 +11,13 @@ edition = "2018"
|
|||
|
||||
[dependencies]
|
||||
thiserror = "1.0.11"
|
||||
activitystreams-derive = { version = "0.2", path = "../activitystreams-derive" }
|
||||
activitystreams-traits = { version = "0.2", path = "../activitystreams-traits" }
|
||||
activitystreams-derive = { version = "0.3", path = "../activitystreams-derive" }
|
||||
activitystreams-traits = { version = "0.3", path = "../activitystreams-traits" }
|
||||
chrono = { version = "0.4", features = ["serde"] }
|
||||
mime = "0.3"
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
typetag = "0.1.4"
|
||||
|
||||
[dev-dependencies]
|
||||
anyhow = "1.0"
|
||||
|
|
|
@ -59,3 +59,47 @@ impl LinkExt for Mention {
|
|||
&mut self.link_props
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[serde(transparent)]
|
||||
pub struct LinkBox(pub Box<dyn Link>);
|
||||
|
||||
impl LinkBox {
|
||||
pub fn is<T>(&self) -> bool
|
||||
where
|
||||
T: Link,
|
||||
{
|
||||
self.0.as_any().is::<T>()
|
||||
}
|
||||
|
||||
pub fn downcast_ref<T>(&self) -> Option<&T>
|
||||
where
|
||||
T: Link,
|
||||
{
|
||||
self.0.as_any().downcast_ref()
|
||||
}
|
||||
|
||||
pub fn downcast_mut<T>(&mut self) -> Option<&mut T>
|
||||
where
|
||||
T: Link,
|
||||
{
|
||||
self.0.as_any_mut().downcast_mut()
|
||||
}
|
||||
|
||||
pub fn downcast<T>(self) -> Option<T>
|
||||
where
|
||||
T: Link,
|
||||
{
|
||||
let any: Box<dyn Any> = self;
|
||||
any.downcast()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> From<T> for LinkBox
|
||||
where
|
||||
T: Link,
|
||||
{
|
||||
fn from(t: T) -> Self {
|
||||
LinkBox(Box::new(t))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -182,7 +182,7 @@ pub struct Place {
|
|||
/// `Actor` Type objects.
|
||||
///
|
||||
/// The `describes` property is used to reference the object being described by the profile.
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize, PropRefs, Properties)]
|
||||
#[derive(Clone, Debug, Default, Deserialize, PropRefs, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Profile {
|
||||
#[serde(rename = "type")]
|
||||
|
@ -215,7 +215,7 @@ pub struct Profile {
|
|||
/// individuals that are directly connected within a person's social graph. Suppose we have a user,
|
||||
/// Sally, with direct relationships to users Joe and Jane. Sally follows Joe's updates while Sally
|
||||
/// and Jane have a mutual relationship.
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties, PropRefs)]
|
||||
#[derive(Clone, Debug, Default, Deserialize, PropRefs, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Relationship {
|
||||
#[serde(rename = "type")]
|
||||
|
@ -271,3 +271,63 @@ pub struct Video {
|
|||
#[activitystreams(Object)]
|
||||
pub object_props: ObjectProperties,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[serde(transparent)]
|
||||
pub struct ImageBox(pub Box<Image>);
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[serde(transparent)]
|
||||
pub struct ObjectBox(pub Box<dyn Object>);
|
||||
|
||||
impl ObjectBox {
|
||||
pub fn is<T>(&self) -> bool
|
||||
where
|
||||
T: Object,
|
||||
{
|
||||
self.0.as_any().is::<T>()
|
||||
}
|
||||
|
||||
pub fn downcast_ref<T>(&self) -> Option<&T>
|
||||
where
|
||||
T: Object,
|
||||
{
|
||||
self.0.as_any().downcast_ref()
|
||||
}
|
||||
|
||||
pub fn downcast_mut<T>(&mut self) -> Option<&mut T>
|
||||
where
|
||||
T: Object,
|
||||
{
|
||||
self.0.as_any_mut().downcast_mut()
|
||||
}
|
||||
|
||||
pub fn downcast<T>(self) -> Option<T>
|
||||
where
|
||||
T: Object,
|
||||
{
|
||||
let any: Box<dyn Any> = self;
|
||||
any.downcast()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Image> for ImageBox {
|
||||
fn from(i: Image) -> Self {
|
||||
ImageBox(Box::new(i))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ImageBox> for Image {
|
||||
fn from(i: ImageBox) -> Self {
|
||||
*i.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> From<T> for ObjectBox
|
||||
where
|
||||
T: Object,
|
||||
{
|
||||
fn from(t: T) -> Self {
|
||||
ObjectBox(Box::new(t))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
//! #[serde(rename = "type")]
|
||||
//! pub kind: String,
|
||||
//!
|
||||
//! /// Define a require property for the MyObject type
|
||||
//! /// Define a required property for the MyObject type
|
||||
//! pub my_property: String,
|
||||
//!
|
||||
//! #[serde(flatten)]
|
||||
|
@ -44,15 +44,16 @@
|
|||
//! # fn main() {}
|
||||
//! ```
|
||||
|
||||
use activitystreams_derive::Properties;
|
||||
use activitystreams_derive::properties;
|
||||
use activitystreams_traits::{Collection, Error, Link, Object, Result};
|
||||
use chrono::{offset::Utc, DateTime};
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
|
||||
use crate::object::Image;
|
||||
|
||||
/// Alias chrono::DateTime<Utc> for use in derive macros
|
||||
pub type UtcTime = DateTime<Utc>;
|
||||
use crate::{
|
||||
link::LinkBox,
|
||||
object::{Image, ObjectBox},
|
||||
primitives::*,
|
||||
};
|
||||
|
||||
/// Define all the properties of the Object base type as described by the Activity Streams
|
||||
/// vocabulary.
|
||||
|
@ -66,417 +67,546 @@ pub type UtcTime = DateTime<Utc>;
|
|||
/// own `type` properties as Unit Structs with custom serde behaviour.
|
||||
///
|
||||
/// All properties are optional (including the id and type).
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ObjectProperties {
|
||||
// TODO: IRI type
|
||||
/// Provides the globally unique identifier for an Object or Link.
|
||||
///
|
||||
/// The `id` property is expressed as an absolute IRI in the spec, but for now is represented
|
||||
/// as a string.
|
||||
///
|
||||
/// - Range: `anyUri`
|
||||
/// - Functional: true
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[serde(alias = "@id")]
|
||||
#[activitystreams(concrete(String), functional)]
|
||||
pub id: Option<serde_json::Value>,
|
||||
properties! {
|
||||
Object {
|
||||
id {
|
||||
/// Provides the globally unique identifier for an Object or Link.
|
||||
///
|
||||
/// The `id` property is expressed as an absolute IRI in the spec, but for now is represented
|
||||
/// as a string.
|
||||
///
|
||||
/// - Range: `xsd:anyUri`
|
||||
/// - Functional: true
|
||||
types [
|
||||
XsdAnyUri,
|
||||
],
|
||||
functional,
|
||||
},
|
||||
|
||||
/// Identifies a resource attached or related to an object that potentially requires special
|
||||
/// handling.
|
||||
///
|
||||
/// The intent is to provide a model that is at least semantically similar to attachments in
|
||||
/// email.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: false
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[activitystreams(ab(Object, Link), concrete(String))]
|
||||
pub attachment: Option<serde_json::Value>,
|
||||
attachment {
|
||||
/// Identifies a resource attached or related to an object that potentially requires special
|
||||
/// handling.
|
||||
///
|
||||
/// The intent is to provide a model that is at least semantically similar to attachments in
|
||||
/// email.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: false
|
||||
types [
|
||||
XsdAnyUri,
|
||||
ObjectBox,
|
||||
LinkBox,
|
||||
],
|
||||
},
|
||||
|
||||
/// Identifies one or more entities to which this object is attributed.
|
||||
///
|
||||
/// The attributed entities might not be Actors. For instance, an object might be attributed to
|
||||
/// the completion of another activity.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: false
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[activitystreams(ab(Object, Link), concrete(String))]
|
||||
pub attributed_to: Option<serde_json::Value>,
|
||||
attributed_to {
|
||||
/// Identifies one or more entities to which this object is attributed.
|
||||
///
|
||||
/// The attributed entities might not be Actors. For instance, an object might be attributed to
|
||||
/// the completion of another activity.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: false
|
||||
types [
|
||||
XsdAnyUri,
|
||||
ObjectBox,
|
||||
LinkBox,
|
||||
],
|
||||
},
|
||||
|
||||
/// Identifies one or more entities that represent the total population of entities for which
|
||||
/// the object can considered to be relevant.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: false
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[activitystreams(ab(Object, Link), concrete(String))]
|
||||
pub audience: Option<serde_json::Value>,
|
||||
audience {
|
||||
/// Identifies one or more entities that represent the total population of entities for which
|
||||
/// the object can considered to be relevant.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: false
|
||||
types [
|
||||
XsdAnyUri,
|
||||
ObjectBox,
|
||||
LinkBox,
|
||||
],
|
||||
},
|
||||
|
||||
// TODO: rdf:langString
|
||||
/// The content or textual representation of the Object encoded as a JSON string.
|
||||
///
|
||||
/// By default, the value of content is HTML. The mediaType property can be used in the object
|
||||
/// to indicate a different content type.
|
||||
///
|
||||
/// The content MAY be expressed using multiple language-tagged values.
|
||||
///
|
||||
/// - Range: `xsd:string` | `rdf:langString`
|
||||
/// - Functional: false
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[activitystreams(concrete(String))]
|
||||
pub content: Option<serde_json::Value>,
|
||||
content {
|
||||
/// The content or textual representation of the Object encoded as a JSON string.
|
||||
///
|
||||
/// By default, the value of content is HTML. The mediaType property can be used in the object
|
||||
/// to indicate a different content type.
|
||||
///
|
||||
/// The content MAY be expressed using multiple language-tagged values.
|
||||
///
|
||||
/// - Range: `xsd:string` | `rdf:langString`
|
||||
/// - Functional: false
|
||||
types [
|
||||
XsdString,
|
||||
RdfLangString,
|
||||
],
|
||||
},
|
||||
|
||||
/// Identifies the context within which the object exists or an activity was performed.
|
||||
///
|
||||
/// The notion of "context" used is intentionally vague. The intended function is to serve as a
|
||||
/// means of grouping objects and activities that share a common originating context or purpose.
|
||||
/// An example could be all activities relating to a common project or event.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: false
|
||||
#[serde(skip_serializing_if = "Option::is_none", rename = "@context")]
|
||||
#[activitystreams(ab(Object, Link), concrete(String))]
|
||||
pub context: Option<serde_json::Value>,
|
||||
context {
|
||||
/// Identifies the context within which the object exists or an activity was performed.
|
||||
///
|
||||
/// The notion of "context" used is intentionally vague. The intended function is to serve as a
|
||||
/// means of grouping objects and activities that share a common originating context or purpose.
|
||||
/// An example could be all activities relating to a common project or event.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: false
|
||||
types [
|
||||
XsdAnyUri,
|
||||
ObjectBox,
|
||||
LinkBox,
|
||||
],
|
||||
},
|
||||
|
||||
// TODO: rdf:langString
|
||||
/// A simple, human-readable, plain-text name for the object.
|
||||
///
|
||||
/// HTML markup MUST NOT be included. The name MAY be expressed using multiple language-tagged
|
||||
/// values.
|
||||
///
|
||||
/// - Range: `xsd:string` | `rdf:langString`
|
||||
/// - Functional: false
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[serde(alias = "displayName")]
|
||||
#[activitystreams(concrete(String))]
|
||||
pub name: Option<serde_json::Value>,
|
||||
name {
|
||||
/// A simple, human-readable, plain-text name for the object.
|
||||
///
|
||||
/// HTML markup MUST NOT be included. The name MAY be expressed using multiple language-tagged
|
||||
/// values.
|
||||
///
|
||||
/// - Range: `xsd:string` | `rdf:langString`
|
||||
/// - Functional: false
|
||||
types [
|
||||
XsdString,
|
||||
RdfLangString,
|
||||
],
|
||||
alias("displayName"),
|
||||
},
|
||||
|
||||
/// The date and time describing the actual or expected ending time of the object.
|
||||
///
|
||||
/// When used with an Activity object, for instance, the endTime property specifies the moment
|
||||
/// the activity concluded or is expected to conclude.
|
||||
///
|
||||
/// - Range: `xsd:dateTime`
|
||||
/// - Functional: true
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[activitystreams(concrete(String, UtcTime), functional)]
|
||||
pub end_time: Option<serde_json::Value>,
|
||||
end_time {
|
||||
/// The date and time describing the actual or expected ending time of the object.
|
||||
///
|
||||
/// When used with an Activity object, for instance, the endTime property specifies the moment
|
||||
/// the activity concluded or is expected to conclude.
|
||||
///
|
||||
/// - Range: `xsd:dateTime`
|
||||
/// - Functional: true
|
||||
types [
|
||||
XsdDateTime,
|
||||
],
|
||||
functional,
|
||||
},
|
||||
|
||||
/// Identifies the entity (e.g. an application) that generated the object.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: false
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[activitystreams(ab(Object, Link), concrete(String))]
|
||||
pub generator: Option<serde_json::Value>,
|
||||
generator {
|
||||
/// Identifies the entity (e.g. an application) that generated the object.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: false
|
||||
types [
|
||||
XsdAnyUri,
|
||||
ObjectBox,
|
||||
LinkBox,
|
||||
],
|
||||
},
|
||||
|
||||
/// Indicates an entity that describes an icon for this object.
|
||||
///
|
||||
/// The image should have an aspect ratio of one (horizontal) to one (vertical) and should be
|
||||
/// suitable for presentation at a small size.
|
||||
///
|
||||
/// - Range: `Image` | `Link`
|
||||
/// - Functional: false
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[activitystreams(ab(Object, Link), concrete(Image, String))]
|
||||
pub icon: Option<serde_json::Value>,
|
||||
icon {
|
||||
/// Indicates an entity that describes an icon for this object.
|
||||
///
|
||||
/// The image should have an aspect ratio of one (horizontal) to one (vertical) and should be
|
||||
/// suitable for presentation at a small size.
|
||||
///
|
||||
/// - Range: `Image` | `Link`
|
||||
/// - Functional: false
|
||||
types [
|
||||
XsdAnyUri,
|
||||
ImageBox,
|
||||
LinkBox,
|
||||
],
|
||||
},
|
||||
|
||||
/// Indicates an entity that describes an image for this object.
|
||||
///
|
||||
/// Unlike the icon property, there are no aspect ratio or display size limitations assumed.
|
||||
///
|
||||
/// - Range: `Image` | `Link`
|
||||
/// - Functional: false
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[activitystreams(ab(Object, Link), concrete(Image, String))]
|
||||
pub image: Option<serde_json::Value>,
|
||||
image {
|
||||
/// Indicates an entity that describes an image for this object.
|
||||
///
|
||||
/// Unlike the icon property, there are no aspect ratio or display size limitations assumed.
|
||||
///
|
||||
/// - Range: `Image` | `Link`
|
||||
/// - Functional: false
|
||||
types [
|
||||
XsdAnyUri,
|
||||
ImageBox,
|
||||
LinkBox,
|
||||
],
|
||||
},
|
||||
|
||||
/// Indicates one or more entities for which this object is considered a response.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: false
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[activitystreams(ab(Object, Link), concrete(String))]
|
||||
pub in_reply_to: Option<serde_json::Value>,
|
||||
in_reply_to {
|
||||
/// Indicates one or more entities for which this object is considered a response.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: false
|
||||
types [
|
||||
XsdAnyUri,
|
||||
ObjectBox,
|
||||
LinkBox,
|
||||
],
|
||||
},
|
||||
|
||||
/// Indicates one or more physical or logical locations associated with the object.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: false
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[activitystreams(ab(Object, Link), concrete(String))]
|
||||
pub location: Option<serde_json::Value>,
|
||||
location {
|
||||
/// Indicates one or more physical or logical locations associated with the object.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: false
|
||||
types [
|
||||
XsdAnyUri,
|
||||
ObjectBox,
|
||||
LinkBox,
|
||||
],
|
||||
},
|
||||
|
||||
/// Identifies an entity that provides a preview of this object.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: false
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[activitystreams(ab(Object, Link), concrete(String))]
|
||||
pub preview: Option<serde_json::Value>,
|
||||
preview {
|
||||
/// Identifies an entity that provides a preview of this object.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: false
|
||||
types [
|
||||
XsdAnyUri,
|
||||
ObjectBox,
|
||||
LinkBox,
|
||||
],
|
||||
},
|
||||
|
||||
/// The date and time at which the object was published.
|
||||
///
|
||||
/// - Range: `xsd:dateTime`
|
||||
/// - Functional: true
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[activitystreams(concrete(String, UtcTime), functional)]
|
||||
pub published: Option<serde_json::Value>,
|
||||
published {
|
||||
/// The date and time at which the object was published.
|
||||
///
|
||||
/// - Range: `xsd:dateTime`
|
||||
/// - Functional: true
|
||||
types [
|
||||
XsdDateTime,
|
||||
],
|
||||
functional,
|
||||
},
|
||||
|
||||
/// Identifies a `Collection` containing objects considered to be responses to this object.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: false
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[activitystreams(ab(Collection), concrete(String), functional)]
|
||||
pub replies: Option<serde_json::Value>,
|
||||
replies {
|
||||
/// Identifies a `Collection` containing objects considered to be responses to this object.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: false
|
||||
types [
|
||||
XsdAnyUri,
|
||||
ObjectBox,
|
||||
LinkBox,
|
||||
],
|
||||
},
|
||||
|
||||
/// The date and time describing the actual or expected starting time of the object.
|
||||
///
|
||||
/// When used with an `Activity` object, for instance, the `start_time` property specifies the
|
||||
/// moment the activity began or is scheduled to begin.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: true
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[activitystreams(concrete(String, UtcTime), functional)]
|
||||
pub start_time: Option<serde_json::Value>,
|
||||
start_time {
|
||||
/// The date and time describing the actual or expected starting time of the object.
|
||||
///
|
||||
/// When used with an `Activity` object, for instance, the `start_time` property specifies the
|
||||
/// moment the activity began or is scheduled to begin.
|
||||
///
|
||||
/// - Range: `xsd:DateTime`
|
||||
/// - Functional: true
|
||||
types [
|
||||
XsdDateTime,
|
||||
],
|
||||
functional,
|
||||
},
|
||||
|
||||
// TODO: rdf:langString
|
||||
/// A natural language summarization of the object encoded as HTML.
|
||||
///
|
||||
/// Multiple language tagged summaries MAY be provided.
|
||||
///
|
||||
/// - Range: `xsd:string` | `rdf:langString`
|
||||
/// - Functional: false
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[activitystreams(concrete(String))]
|
||||
pub summary: Option<serde_json::Value>,
|
||||
summary {
|
||||
/// A natural language summarization of the object encoded as HTML.
|
||||
///
|
||||
/// Multiple language tagged summaries MAY be provided.
|
||||
///
|
||||
/// - Range: `xsd:string` | `rdf:langString`
|
||||
/// - Functional: false
|
||||
types [
|
||||
XsdString,
|
||||
RdfLangString,
|
||||
],
|
||||
},
|
||||
|
||||
/// One or more "tags" that have been associated with an objects. A tag can be any kind of
|
||||
/// `Object`.
|
||||
///
|
||||
/// The key difference between attachment and tag is that the former implies association by
|
||||
/// inclusion, while the latter implies associated by reference.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: false
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[activitystreams(ab(Object, Link), concrete(String))]
|
||||
pub tag: Option<serde_json::Value>,
|
||||
tag {
|
||||
/// One or more "tags" that have been associated with an objects. A tag can be any kind of
|
||||
/// `Object`.
|
||||
///
|
||||
/// The key difference between attachment and tag is that the former implies association by
|
||||
/// inclusion, while the latter implies associated by reference.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: false
|
||||
types [
|
||||
XsdAnyUri,
|
||||
ObjectBox,
|
||||
LinkBox,
|
||||
],
|
||||
},
|
||||
|
||||
/// The date and time at which the object was updated,
|
||||
///
|
||||
/// - Range: `xsd:dateTime`
|
||||
/// - Functional: true
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[activitystreams(concrete(String, UtcTime), functional)]
|
||||
pub updated: Option<serde_json::Value>,
|
||||
updated {
|
||||
/// The date and time at which the object was updated,
|
||||
///
|
||||
/// - Range: `xsd:dateTime`
|
||||
/// - Functional: true
|
||||
types [
|
||||
XsdDateTime,
|
||||
],
|
||||
functional,
|
||||
},
|
||||
|
||||
/// Identifies one or more links to representations of the object.
|
||||
///
|
||||
/// - Range: `xsd:anyUri` | `Link`
|
||||
/// - Functional: false
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[activitystreams(concrete(String), ab(Link))]
|
||||
pub url: Option<serde_json::Value>,
|
||||
url {
|
||||
/// Identifies one or more links to representations of the object.
|
||||
///
|
||||
/// - Range: `xsd:anyUri` | `Link`
|
||||
/// - Functional: false
|
||||
types [
|
||||
XsdAnyUri,
|
||||
LinkBox,
|
||||
],
|
||||
},
|
||||
|
||||
/// Identifies an entity considered to be part of the public primary audience of an `Object`.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: false
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[activitystreams(ab(Object, Link), concrete(String))]
|
||||
pub to: Option<serde_json::Value>,
|
||||
to {
|
||||
/// Identifies an entity considered to be part of the public primary audience of an `Object`.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: false
|
||||
types [
|
||||
XsdAnyUri,
|
||||
ObjectBox,
|
||||
LinkBox,
|
||||
],
|
||||
},
|
||||
|
||||
/// Identifies an `Object` that is part of the private primary audience of this `Object`.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: false
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[activitystreams(ab(Object, Link), concrete(String))]
|
||||
pub bto: Option<serde_json::Value>,
|
||||
bto {
|
||||
/// Identifies an `Object` that is part of the private primary audience of this `Object`.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: false
|
||||
types [
|
||||
XsdAnyUri,
|
||||
ObjectBox,
|
||||
LinkBox,
|
||||
],
|
||||
},
|
||||
|
||||
/// Identifies an `Object` that is part of the public secondary audience of this `Object`.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: false
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[activitystreams(ab(Object, Link), concrete(String))]
|
||||
pub cc: Option<serde_json::Value>,
|
||||
cc {
|
||||
/// Identifies an `Object` that is part of the public secondary audience of this `Object`.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: false
|
||||
types [
|
||||
XsdAnyUri,
|
||||
ObjectBox,
|
||||
LinkBox,
|
||||
],
|
||||
},
|
||||
|
||||
/// Identifies one or more `Objects` that are part of the private secondary audience of this
|
||||
/// `Object`.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: false
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[activitystreams(ab(Object, Link), concrete(String))]
|
||||
pub bcc: Option<serde_json::Value>,
|
||||
bcc {
|
||||
/// Identifies one or more `Objects` that are part of the private secondary audience of this
|
||||
/// `Object`.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: false
|
||||
types [
|
||||
XsdAnyUri,
|
||||
ObjectBox,
|
||||
LinkBox,
|
||||
],
|
||||
},
|
||||
|
||||
/// When used on an `Object`, identifies the MIME media type of the value of the content
|
||||
/// property.
|
||||
///
|
||||
/// If not specified, the content property is assumed to contain text/html content.
|
||||
///
|
||||
/// - Range: `Mime Media Type`
|
||||
/// - Functional: true
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[activitystreams(concrete(String), functional)]
|
||||
pub media_type: Option<serde_json::Value>,
|
||||
media_type {
|
||||
/// When used on an `Object`, identifies the MIME media type of the value of the content
|
||||
/// property.
|
||||
///
|
||||
/// If not specified, the content property is assumed to contain text/html content.
|
||||
///
|
||||
/// - Range: `Mime Media Type`
|
||||
/// - Functional: true
|
||||
types [
|
||||
MimeMediaType,
|
||||
],
|
||||
functional,
|
||||
},
|
||||
|
||||
// TODO: xsd:duration
|
||||
/// When the object describes a time-bound resource, such as an audio or video, a meeting, etc,
|
||||
/// the duration property indicates the object's approximate duration.
|
||||
///
|
||||
/// The value MUST be expressed as an xsd:duration as defined by
|
||||
/// [[xmlschema11-2](https://www.w3.org/TR/xmlschema11-2/)], section
|
||||
/// 3.3.6 (e.g. a period of 5 seconds is represented as "PT5S").
|
||||
///
|
||||
/// - Range: `xsd:duration`
|
||||
/// - Functional: true
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[activitystreams(concrete(String), functional)]
|
||||
pub duration: Option<serde_json::Value>,
|
||||
}
|
||||
|
||||
impl ObjectProperties {
|
||||
/// Fetch a typed `Mime` struct from the `media_type` field.
|
||||
pub fn media_type(&self) -> Result<mime::Mime> {
|
||||
self.media_type_string()
|
||||
.and_then(|s| s.parse().map_err(|_| Error::Deserialize))
|
||||
duration {
|
||||
/// When the object describes a time-bound resource, such as an audio or video, a meeting, etc,
|
||||
/// the duration property indicates the object's approximate duration.
|
||||
///
|
||||
/// The value MUST be expressed as an xsd:duration as defined by
|
||||
/// [[xmlschema11-2](https://www.w3.org/TR/xmlschema11-2/)], section
|
||||
/// 3.3.6 (e.g. a period of 5 seconds is represented as "PT5S").
|
||||
///
|
||||
/// - Range: `xsd:duration`
|
||||
/// - Functional: true
|
||||
types [
|
||||
XsdDuration,
|
||||
],
|
||||
functional,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Define all the properties of the Location type as described by the Activity Streams vocabulary.
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct PlaceProperties {
|
||||
/// Indicates the accuracy of position coordinates on a `Place` objects.
|
||||
///
|
||||
/// Expressed in properties of percentage. e.g. "94.0" means "94.0% accurate".
|
||||
///
|
||||
/// - Range: `xsd:float` [>= 0.0f, <= 100.0f]
|
||||
/// - Functional: true
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[activitystreams(concrete(f64), functional)]
|
||||
pub accuracy: Option<serde_json::Value>,
|
||||
properties! {
|
||||
Place {
|
||||
accuracy {
|
||||
/// Indicates the accuracy of position coordinates on a `Place` objects.
|
||||
///
|
||||
/// Expressed in properties of percentage. e.g. "94.0" means "94.0% accurate".
|
||||
///
|
||||
/// - Range: `xsd:float` [>= 0.0f, <= 100.0f]
|
||||
/// - Functional: true
|
||||
types [
|
||||
XsdFloat,
|
||||
],
|
||||
functional,
|
||||
},
|
||||
|
||||
/// Indicates the altitude of a place. The measurement units is indicated using the units
|
||||
/// property.
|
||||
///
|
||||
/// If units is not specified, the default is assumed to be "m" indicating meters.
|
||||
///
|
||||
/// - Range: `xsd:float`
|
||||
/// - Functional: true
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[activitystreams(concrete(f64), functional)]
|
||||
pub altitude: Option<serde_json::Value>,
|
||||
altitude {
|
||||
/// Indicates the altitude of a place. The measurement units is indicated using the units
|
||||
/// property.
|
||||
///
|
||||
/// If units is not specified, the default is assumed to be "m" indicating meters.
|
||||
///
|
||||
/// - Range: `xsd:float`
|
||||
/// - Functional: true
|
||||
types [
|
||||
XsdFloat,
|
||||
],
|
||||
functional,
|
||||
},
|
||||
|
||||
/// The latitude of a place.
|
||||
///
|
||||
/// - Range: `xsd:float`
|
||||
/// - Functional: true
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[activitystreams(concrete(f64), functional)]
|
||||
pub latitude: Option<serde_json::Value>,
|
||||
latitude {
|
||||
/// The latitude of a place.
|
||||
///
|
||||
/// - Range: `xsd:float`
|
||||
/// - Functional: true
|
||||
types [
|
||||
XsdFloat,
|
||||
],
|
||||
functional,
|
||||
}
|
||||
|
||||
/// The longitude of a place.
|
||||
///
|
||||
/// - Range: `xsd:float`
|
||||
/// - Functional: true
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[activitystreams(concrete(f64), functional)]
|
||||
pub longitude: Option<serde_json::Value>,
|
||||
logitude {
|
||||
/// The longitude of a place.
|
||||
///
|
||||
/// - Range: `xsd:float`
|
||||
/// - Functional: true
|
||||
types [
|
||||
XsdFloat,
|
||||
],
|
||||
functional,
|
||||
},
|
||||
|
||||
/// The radius from the given latitude and longitude for a Place.
|
||||
///
|
||||
/// The units is expressed by the units property. If units is not specified, the default is
|
||||
/// assumed to be "m" indicating "meters".
|
||||
///
|
||||
/// - Range: `xsd:float`
|
||||
/// - Functional: true
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[activitystreams(concrete(f64), functional)]
|
||||
pub radius: Option<serde_json::Value>,
|
||||
radius {
|
||||
/// The radius from the given latitude and longitude for a Place.
|
||||
///
|
||||
/// The units is expressed by the units property. If units is not specified, the default is
|
||||
/// assumed to be "m" indicating "meters".
|
||||
///
|
||||
/// - Range: `xsd:float`
|
||||
/// - Functional: true
|
||||
types [
|
||||
XsdFloat,
|
||||
],
|
||||
functional,
|
||||
},
|
||||
|
||||
/// Specifies the measurement units for the radius and altitude properties on a `Place` object.
|
||||
///
|
||||
/// If not specified, the default is assumed to be "m" for "meters".
|
||||
///
|
||||
/// - Range: `xsd:float`
|
||||
/// - Functional: true
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[activitystreams(concrete(String), functional)]
|
||||
pub units: Option<serde_json::Value>,
|
||||
units {
|
||||
/// Specifies the measurement units for the radius and altitude properties on a `Place` object.
|
||||
///
|
||||
/// If not specified, the default is assumed to be "m" for "meters".
|
||||
///
|
||||
/// TODO: encode rage as any of `"cm"` | `"feet"` | `"inches"` | `"km"` | `"m"` | `xsd:anyUri`
|
||||
/// - Range: `xsd:anyUri` | `xsd:string`
|
||||
/// - Functional: true
|
||||
types [
|
||||
XsdAnyUri,
|
||||
XsdString,
|
||||
],
|
||||
functional,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Define all the properties of the Profile type as described by the Activity Streams vocabulary.
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ProfileProperties {
|
||||
/// On a `Profile` object, the describes property identifies the object described by the
|
||||
/// `Profile`.
|
||||
///
|
||||
/// - Range: `Object`
|
||||
/// - Functional: true
|
||||
#[activitystreams(ab(Object), concrete(String), functional)]
|
||||
pub describes: serde_json::Value,
|
||||
properties! {
|
||||
Profile {
|
||||
describes {
|
||||
/// On a `Profile` object, the describes property identifies the object described by the
|
||||
/// `Profile`.
|
||||
///
|
||||
/// - Range: `Object`
|
||||
/// - Functional: true
|
||||
types [
|
||||
XsdAnyUri,
|
||||
ObjectBox,
|
||||
],
|
||||
functional,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Define all the properties of the Relationship type as described by the Activity Streams
|
||||
/// vocabulary.
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RelationshipProperties {
|
||||
/// On a `Relationship` object, the subject property identifies one of the connected
|
||||
/// individuals.
|
||||
///
|
||||
/// For instance, for a `Relationship` object describing "John is related to Sally", subject
|
||||
/// would refer to John.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: true
|
||||
#[activitystreams(ab(Object, Link), concrete(String), functional)]
|
||||
subject: serde_json::Value,
|
||||
properties! {
|
||||
Relationship {
|
||||
subject {
|
||||
/// On a `Relationship` object, the subject property identifies one of the connected
|
||||
/// individuals.
|
||||
///
|
||||
/// For instance, for a `Relationship` object describing "John is related to Sally", subject
|
||||
/// would refer to John.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: true
|
||||
types [
|
||||
XsdAnyUri,
|
||||
ObjectBox,
|
||||
LinkBox,
|
||||
],
|
||||
functional,
|
||||
},
|
||||
|
||||
/// When used within a `Relationship` describes the entity to which the subject is related.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: false
|
||||
#[activitystreams(ab(Object, Link), concrete(String))]
|
||||
object: serde_json::Value,
|
||||
object {
|
||||
/// When used within a `Relationship` describes the entity to which the subject is related.
|
||||
///
|
||||
/// - Range: `Object` | `Link`
|
||||
/// - Functional: false
|
||||
types [
|
||||
XsdAnyUri,
|
||||
ObjectBox,
|
||||
LinkBox,
|
||||
],
|
||||
},
|
||||
|
||||
/// On a `Relationship` object, the relationship property identifies the kind of relationship
|
||||
/// that exists between subject and object.
|
||||
///
|
||||
/// - Range: `Object`
|
||||
/// - Functional: false
|
||||
#[activitystreams(ab(Object), concrete(String))]
|
||||
relationship: serde_json::Value,
|
||||
relationship {
|
||||
/// On a `Relationship` object, the relationship property identifies the kind of relationship
|
||||
/// that exists between subject and object.
|
||||
///
|
||||
/// - Range: `Object`
|
||||
/// - Functional: false
|
||||
types [
|
||||
XsdAnyUri,
|
||||
ObjectBox,
|
||||
],
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Define all the properties of the Tombstone type as described by the Activity Streams vocabulary.
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct TombstoneProperties {
|
||||
/// On a `Tombstone` object, the formerType property identifies the type of the object that was
|
||||
/// deleted.
|
||||
///
|
||||
/// - Range: `Object`
|
||||
/// - Functional: false
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[activitystreams(ab(Object), concrete(String))]
|
||||
pub former_type: Option<serde_json::Value>,
|
||||
properties! {
|
||||
Tombstone {
|
||||
former_type {
|
||||
/// On a `Tombstone` object, the formerType property identifies the type of the object that was
|
||||
/// deleted.
|
||||
///
|
||||
/// - Range: `Object`
|
||||
/// - Functional: false
|
||||
types [
|
||||
XsdAnyUri,
|
||||
ObjectBox,
|
||||
],
|
||||
},
|
||||
|
||||
/// On a `Tombstone` object, the deleted property is a timestamp for when the object was
|
||||
/// deleted.
|
||||
///
|
||||
/// - Range: `xsd:dateTime`
|
||||
/// - Functional: true
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[activitystreams(concrete(String, UtcTime), functional)]
|
||||
pub deleted: Option<serde_json::Value>,
|
||||
deleted {
|
||||
/// On a `Tombstone` object, the deleted property is a timestamp for when the object was
|
||||
/// deleted.
|
||||
///
|
||||
/// - Range: `xsd:dateTime`
|
||||
/// - Functional: true
|
||||
types [
|
||||
XsdDateTime,
|
||||
],
|
||||
functional,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue