Start documenting object fields

This commit is contained in:
asonix 2020-05-16 12:20:34 -05:00
parent ca04dc05d7
commit f4a111b5e2
2 changed files with 171 additions and 1 deletions

View file

@ -320,7 +320,6 @@ pub mod prelude {
//! .set_media_type("image/png".parse()?) //! .set_media_type("image/png".parse()?)
//! .set_id("https://localhostst:8080/preview.png".parse()?); //! .set_id("https://localhostst:8080/preview.png".parse()?);
//! //!
//!
//! let mut video = ApObject::<Video>::default(); //! let mut video = ApObject::<Video>::default();
//! //!
//! video //! video

View file

@ -1339,90 +1339,223 @@ pub type Note = Object<NoteType>;
pub type Page = Object<PageType>; pub type Page = Object<PageType>;
pub type Video = Object<VideoType>; pub type Video = Object<VideoType>;
/// Define all the properties of the Object base type as described by the Activity Streams
/// vocabulary.
#[derive(Clone, Debug, Default, serde::Deserialize, serde::Serialize, TypedBuilder)] #[derive(Clone, Debug, Default, serde::Deserialize, serde::Serialize, TypedBuilder)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[builder(doc)] #[builder(doc)]
pub struct Object<Kind> { pub struct Object<Kind> {
/// 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")] #[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option, into))] #[builder(default, setter(strip_option, into))]
pub attachment: Option<OneOrMany<AnyBase>>, pub attachment: Option<OneOrMany<AnyBase>>,
/// 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")] #[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option, into))] #[builder(default, setter(strip_option, into))]
pub attributed_to: Option<OneOrMany<AnyBase>>, pub attributed_to: Option<OneOrMany<AnyBase>>,
/// 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")] #[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option, into))] #[builder(default, setter(strip_option, into))]
pub audience: Option<OneOrMany<AnyBase>>, pub audience: Option<OneOrMany<AnyBase>>,
/// 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")] #[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option, into))] #[builder(default, setter(strip_option, into))]
pub content: Option<OneOrMany<AnyString>>, pub content: Option<OneOrMany<AnyString>>,
/// 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")] #[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option, into))] #[builder(default, setter(strip_option, into))]
pub summary: Option<OneOrMany<AnyString>>, pub summary: Option<OneOrMany<AnyString>>,
/// Identifies one or more links to representations of the object.
///
/// - Range: xsd:anyUri | Link
/// - Functional: false
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option, into))] #[builder(default, setter(strip_option, into))]
pub url: Option<OneOrMany<AnyBase>>, pub url: Option<OneOrMany<AnyBase>>,
/// Identifies the entity (e.g. an application) that generated the object.
///
/// - Range: Object | Link
/// - Functional: false
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option, into))] #[builder(default, setter(strip_option, into))]
pub generator: Option<OneOrMany<AnyBase>>, pub generator: Option<OneOrMany<AnyBase>>,
/// 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")]
#[builder(default, setter(strip_option, into))]
pub icon: Option<OneOrMany<AnyBase>>,
/// 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")] #[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option, into))] #[builder(default, setter(strip_option, into))]
pub image: Option<OneOrMany<AnyBase>>, pub image: Option<OneOrMany<AnyBase>>,
/// Indicates one or more physical or logical locations associated with the object.
///
/// - Range: Object | Link
/// - Functional: false
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option, into))] #[builder(default, setter(strip_option, into))]
pub location: Option<OneOrMany<AnyBase>>, pub location: Option<OneOrMany<AnyBase>>,
/// 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")]
#[builder(default, setter(strip_option, into))]
pub tag: Option<OneOrMany<AnyBase>>,
/// 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
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option, into))] #[builder(default, setter(strip_option, into))]
pub start_time: Option<XsdDateTime>, pub start_time: Option<XsdDateTime>,
/// 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")] #[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option, into))] #[builder(default, setter(strip_option, into))]
pub end_time: Option<XsdDateTime>, pub end_time: Option<XsdDateTime>,
/// 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")] #[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))] #[builder(default, setter(strip_option))]
pub duration: Option<XsdDuration>, pub duration: Option<XsdDuration>,
/// The date and time at which the object was published.
///
/// - Range: xsd:dateTime
/// - Functional: true
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option, into))] #[builder(default, setter(strip_option, into))]
pub published: Option<XsdDateTime>, pub published: Option<XsdDateTime>,
/// The date and time at which the object was updated,
///
/// - Range: xsd:dateTime
/// - Functional: true
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option, into))] #[builder(default, setter(strip_option, into))]
pub updated: Option<XsdDateTime>, pub updated: Option<XsdDateTime>,
/// 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")] #[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option, into))] #[builder(default, setter(strip_option, into))]
pub in_reply_to: Option<OneOrMany<AnyBase>>, pub in_reply_to: Option<OneOrMany<AnyBase>>,
/// Identifies a Collection containing objects considered to be responses to this object.
///
/// - Range: Object | Link
/// - Functional: false
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option, into))] #[builder(default, setter(strip_option, into))]
pub replies: Option<OneOrMany<AnyBase>>, pub replies: Option<OneOrMany<AnyBase>>,
/// 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")] #[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option, into))] #[builder(default, setter(strip_option, into))]
pub to: Option<OneOrMany<AnyBase>>, pub to: Option<OneOrMany<AnyBase>>,
/// 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")] #[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option, into))] #[builder(default, setter(strip_option, into))]
pub bto: Option<OneOrMany<AnyBase>>, pub bto: Option<OneOrMany<AnyBase>>,
/// 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")] #[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option, into))] #[builder(default, setter(strip_option, into))]
pub cc: Option<OneOrMany<AnyBase>>, pub cc: Option<OneOrMany<AnyBase>>,
/// 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")] #[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option, into))] #[builder(default, setter(strip_option, into))]
pub bcc: Option<OneOrMany<AnyBase>>, pub bcc: Option<OneOrMany<AnyBase>>,
/// Base fields and unparsed json ends up here
#[serde(flatten)] #[serde(flatten)]
pub inner: Base<Kind>, pub inner: Base<Kind>,
} }
@ -1431,22 +1564,60 @@ pub struct Object<Kind> {
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[builder(doc)] #[builder(doc)]
pub struct ApObject<Inner> { pub struct ApObject<Inner> {
/// This is a list of all Announce activities with this object as the object property, added as
/// a side effect.
///
/// The shares collection MUST be either an OrderedCollection or a Collection and MAY be
/// filtered on privileges of an authenticated user or as appropriate when no authentication is
/// given.
///
/// - Range: anyUri
/// - Functional: true
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))] #[builder(default, setter(strip_option))]
pub shares: Option<XsdAnyUri>, pub shares: Option<XsdAnyUri>,
/// This is a list of all Like activities with this object as the object property, added as a
/// side effect.
///
/// The likes collection MUST be either an OrderedCollection or a Collection and MAY be
/// filtered on privileges of an authenticated user or as appropriate when no authentication is
/// given.
///
/// - Range: anyUri
/// - Functional: true
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))] #[builder(default, setter(strip_option))]
pub likes: Option<XsdAnyUri>, pub likes: Option<XsdAnyUri>,
/// The source property is intended to convey some sort of source from which the content markup
/// was derived, as a form of provenance, or to support future editing by clients.
///
/// In general, clients do the conversion from source to content, not the other way around.
///
/// The value of source is itself an object which uses its own content and mediaType fields to
/// supply source information.
///
/// - Range: Object
/// - Functional: true
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option, into))] #[builder(default, setter(strip_option, into))]
pub source: Option<AnyBase>, pub source: Option<AnyBase>,
/// Servers MAY support uploading document types to be referenced in activites, such as images,
/// video or other binary data, but the precise mechanism is out of scope for this version of
/// ActivityPub.
///
/// The Social Web Community Group is refining the protocol in the
/// [ActivityPub Media Upload report](https://www.w3.org/wiki/SocialCG/ActivityPub/MediaUpload).
///
/// - Range: anyUri
/// - Functional: false
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option, into))] #[builder(default, setter(strip_option, into))]
pub upload_media: Option<OneOrMany<XsdAnyUri>>, pub upload_media: Option<OneOrMany<XsdAnyUri>>,
/// The ActivityStreams object being extended
#[serde(flatten)] #[serde(flatten)]
pub inner: Inner, pub inner: Inner,
} }