Move Extension traits out of properties modules

This commit is contained in:
asonix 2018-08-03 22:43:01 -05:00
parent 16d06bf550
commit ef7ebb8db2
41 changed files with 124 additions and 101 deletions

View file

@ -21,9 +21,10 @@ use activitystreams_traits::{Activity, Object};
use super::{ use super::{
kind::AcceptType, kind::AcceptType,
properties::{AcceptProperties, ActivityExt, ActivityProperties}, properties::{AcceptProperties, ActivityProperties},
ActivityExt,
}; };
use object::properties::{ObjectExt, ObjectProperties}; use object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor accepts the object. /// Indicates that the actor accepts the object.
/// ///

View file

@ -21,9 +21,10 @@ use activitystreams_traits::{Activity, Object};
use super::{ use super::{
kind::AddType, kind::AddType,
properties::{ActivityExt, ActivityProperties, AddProperties}, properties::{ActivityProperties, AddProperties},
ActivityExt,
}; };
use object::properties::{ObjectExt, ObjectProperties}; use object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor has added the object to the target. /// Indicates that the actor has added the object to the target.
/// ///

View file

@ -21,9 +21,10 @@ use activitystreams_traits::{Activity, Object};
use super::{ use super::{
kind::MoveType, kind::MoveType,
properties::{ActivityExt, ActivityProperties, MoveProperties}, properties::{ActivityProperties, MoveProperties},
ActivityExt,
}; };
use object::properties::{ObjectExt, ObjectProperties}; use object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor has moved object from origin to target. /// Indicates that the actor has moved object from origin to target.
/// ///

View file

@ -21,9 +21,10 @@ use activitystreams_traits::{Activity, Object};
use super::{ use super::{
kind::AnnounceType, kind::AnnounceType,
properties::{ActivityExt, ActivityProperties, AnnounceProperties}, properties::{ActivityProperties, AnnounceProperties},
ActivityExt,
}; };
use object::properties::{ObjectExt, ObjectProperties}; use object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor is calling the target's attention the object. /// Indicates that the actor is calling the target's attention the object.
/// ///

View file

@ -21,9 +21,10 @@ use activitystreams_traits::{Activity, IntransitiveActivity, Object};
use super::{ use super::{
kind::ArriveType, kind::ArriveType,
properties::{ActivityExt, ActivityProperties, ArriveProperties}, properties::{ActivityProperties, ArriveProperties},
ActivityExt,
}; };
use object::properties::{ObjectExt, ObjectProperties}; use object::{properties::ObjectProperties, ObjectExt};
/// An IntransitiveActivity that indicates that the actor has arrived at the location. /// An IntransitiveActivity that indicates that the actor has arrived at the location.
/// ///

View file

@ -21,9 +21,10 @@ use activitystreams_traits::{Activity, Object};
use super::{ use super::{
kind::BlockType, kind::BlockType,
properties::{ActivityExt, ActivityProperties, BlockProperties}, properties::{ActivityProperties, BlockProperties},
ActivityExt,
}; };
use object::properties::{ObjectExt, ObjectProperties}; use object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor is blocking the object. /// Indicates that the actor is blocking the object.
/// ///

View file

@ -21,9 +21,10 @@ use activitystreams_traits::{Activity, Object};
use super::{ use super::{
kind::CreateType, kind::CreateType,
properties::{ActivityExt, ActivityProperties, CreateProperties}, properties::{ActivityProperties, CreateProperties},
ActivityExt,
}; };
use object::properties::{ObjectExt, ObjectProperties}; use object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor has created the object. /// Indicates that the actor has created the object.
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]

View file

@ -21,9 +21,10 @@ use activitystreams_traits::{Activity, Object};
use super::{ use super::{
kind::DeleteType, kind::DeleteType,
properties::{ActivityExt, ActivityProperties, DeleteProperties}, properties::{ActivityProperties, DeleteProperties},
ActivityExt,
}; };
use object::properties::{ObjectExt, ObjectProperties}; use object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor has deleted the object. /// Indicates that the actor has deleted the object.
/// ///

View file

@ -21,9 +21,10 @@ use activitystreams_traits::{Activity, Object};
use super::{ use super::{
kind::DislikeType, kind::DislikeType,
properties::{ActivityExt, ActivityProperties, DislikeProperties}, properties::{ActivityProperties, DislikeProperties},
ActivityExt,
}; };
use object::properties::{ObjectExt, ObjectProperties}; use object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor dislikes the object. /// Indicates that the actor dislikes the object.
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]

View file

@ -21,9 +21,10 @@ use activitystreams_traits::{Activity, Object};
use super::{ use super::{
kind::FlagType, kind::FlagType,
properties::{ActivityExt, ActivityProperties, FlagProperties}, properties::{ActivityProperties, FlagProperties},
ActivityExt,
}; };
use object::properties::{ObjectExt, ObjectProperties}; use object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor is "flagging" the object. /// Indicates that the actor is "flagging" the object.
/// ///

View file

@ -21,9 +21,10 @@ use activitystreams_traits::{Activity, Object};
use super::{ use super::{
kind::FollowType, kind::FollowType,
properties::{ActivityExt, ActivityProperties, FollowProperties}, properties::{ActivityProperties, FollowProperties},
ActivityExt,
}; };
use object::properties::{ObjectExt, ObjectProperties}; use object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor is "following" the object. /// Indicates that the actor is "following" the object.
/// ///

View file

@ -21,9 +21,10 @@ use activitystreams_traits::{Activity, Object};
use super::{ use super::{
kind::IgnoreType, kind::IgnoreType,
properties::{ActivityExt, ActivityProperties, IgnoreProperties}, properties::{ActivityProperties, IgnoreProperties},
ActivityExt,
}; };
use object::properties::{ObjectExt, ObjectProperties}; use object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor is ignoring the object. /// Indicates that the actor is ignoring the object.
/// ///

View file

@ -21,9 +21,10 @@ use activitystreams_traits::{Activity, Object};
use super::{ use super::{
kind::InviteType, kind::InviteType,
properties::{ActivityExt, ActivityProperties, InviteProperties}, properties::{ActivityProperties, InviteProperties},
ActivityExt,
}; };
use object::properties::{ObjectExt, ObjectProperties}; use object::{properties::ObjectProperties, ObjectExt};
/// A specialization of Offer in which the actor is extending an invitation for the object to the /// A specialization of Offer in which the actor is extending an invitation for the object to the
/// target. /// target.

View file

@ -21,9 +21,10 @@ use activitystreams_traits::{Activity, Object};
use super::{ use super::{
kind::JoinType, kind::JoinType,
properties::{ActivityExt, ActivityProperties, JoinProperties}, properties::{ActivityProperties, JoinProperties},
ActivityExt,
}; };
use object::properties::{ObjectExt, ObjectProperties}; use object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor has joined the object. /// Indicates that the actor has joined the object.
/// ///

View file

@ -21,9 +21,10 @@ use activitystreams_traits::{Activity, Object};
use super::{ use super::{
kind::LeaveType, kind::LeaveType,
properties::{ActivityExt, ActivityProperties, LeaveProperties}, properties::{ActivityProperties, LeaveProperties},
ActivityExt,
}; };
use object::properties::{ObjectExt, ObjectProperties}; use object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor has left the object. /// Indicates that the actor has left the object.
/// ///

View file

@ -21,9 +21,10 @@ use activitystreams_traits::{Activity, Object};
use super::{ use super::{
kind::LikeType, kind::LikeType,
properties::{ActivityExt, ActivityProperties, LikeProperties}, properties::{ActivityProperties, LikeProperties},
ActivityExt,
}; };
use object::properties::{ObjectExt, ObjectProperties}; use object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor likes, recommends or endorses the object. /// Indicates that the actor likes, recommends or endorses the object.
/// ///

View file

@ -21,9 +21,10 @@ use activitystreams_traits::{Activity, Object};
use super::{ use super::{
kind::ListenType, kind::ListenType,
properties::{ActivityExt, ActivityProperties, ListenProperties}, properties::{ActivityProperties, ListenProperties},
ActivityExt,
}; };
use object::properties::{ObjectExt, ObjectProperties}; use object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor has listened to the object. /// Indicates that the actor has listened to the object.
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]

View file

@ -76,3 +76,12 @@ pub use self::travel::*;
pub use self::undo::*; pub use self::undo::*;
pub use self::update::*; pub use self::update::*;
pub use self::view::*; pub use self::view::*;
use activitystreams_traits::Activity;
use self::properties::ActivityProperties;
pub trait ActivityExt: Activity {
fn props(&self) -> &ActivityProperties;
fn props_mut(&mut self) -> &mut ActivityProperties;
}

View file

@ -21,9 +21,10 @@ use activitystreams_traits::{Activity, Object};
use super::{ use super::{
kind::OfferType, kind::OfferType,
properties::{ActivityExt, ActivityProperties, OfferProperties}, properties::{ActivityProperties, OfferProperties},
ActivityExt,
}; };
use object::properties::{ObjectExt, ObjectProperties}; use object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor is offering the object. /// Indicates that the actor is offering the object.
/// ///

View file

@ -56,14 +56,9 @@
//! # fn main() {} //! # fn main() {}
//! ``` //! ```
use activitystreams_traits::{Activity, Link, Object}; use activitystreams_traits::{Link, Object};
use serde_json; use serde_json;
pub trait ActivityExt: Activity {
fn props(&self) -> &ActivityProperties;
fn props_mut(&mut self) -> &mut ActivityProperties;
}
/// Activity objects are specializations of the base Object type that provide information about /// Activity objects are specializations of the base Object type that provide information about
/// actions that have either already occurred, are in the process of occurring, or may occur in the /// actions that have either already occurred, are in the process of occurring, or may occur in the
/// future. /// future.

View file

@ -21,9 +21,10 @@ use activitystreams_traits::{Activity, IntransitiveActivity, Object};
use super::{ use super::{
kind::QuestionType, kind::QuestionType,
properties::{ActivityExt, ActivityProperties, QuestionProperties}, properties::{ActivityProperties, QuestionProperties},
ActivityExt,
}; };
use object::properties::{ObjectExt, ObjectProperties}; use object::{properties::ObjectProperties, ObjectExt};
/// Represents a question being asked. /// Represents a question being asked.
/// ///

View file

@ -21,9 +21,10 @@ use activitystreams_traits::{Activity, Object};
use super::{ use super::{
kind::ReadType, kind::ReadType,
properties::{ActivityExt, ActivityProperties, ReadProperties}, properties::{ActivityProperties, ReadProperties},
ActivityExt,
}; };
use object::properties::{ObjectExt, ObjectProperties}; use object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor has read the object. /// Indicates that the actor has read the object.
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]

View file

@ -21,9 +21,10 @@ use activitystreams_traits::{Activity, Object};
use super::{ use super::{
kind::RejectType, kind::RejectType,
properties::{ActivityExt, ActivityProperties, RejectProperties}, properties::{ActivityProperties, RejectProperties},
ActivityExt,
}; };
use object::properties::{ObjectExt, ObjectProperties}; use object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor is rejecting the object. /// Indicates that the actor is rejecting the object.
/// ///

View file

@ -21,9 +21,10 @@ use activitystreams_traits::{Activity, Object};
use super::{ use super::{
kind::RemoveType, kind::RemoveType,
properties::{ActivityExt, ActivityProperties, RemoveProperties}, properties::{ActivityProperties, RemoveProperties},
ActivityExt,
}; };
use object::properties::{ObjectExt, ObjectProperties}; use object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor is removing the object. /// Indicates that the actor is removing the object.
/// ///

View file

@ -21,9 +21,10 @@ use activitystreams_traits::{Activity, Object};
use super::{ use super::{
kind::TentativeAcceptType, kind::TentativeAcceptType,
properties::{ActivityExt, ActivityProperties, TentativeAcceptProperties}, properties::{ActivityProperties, TentativeAcceptProperties},
ActivityExt,
}; };
use object::properties::{ObjectExt, ObjectProperties}; use object::{properties::ObjectProperties, ObjectExt};
/// A specialization of Accept indicating that the acceptance is tentative. /// A specialization of Accept indicating that the acceptance is tentative.
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]

View file

@ -21,9 +21,10 @@ use activitystreams_traits::{Activity, Object};
use super::{ use super::{
kind::TentativeRejectType, kind::TentativeRejectType,
properties::{ActivityExt, ActivityProperties, TentativeRejectProperties}, properties::{ActivityProperties, TentativeRejectProperties},
ActivityExt,
}; };
use object::properties::{ObjectExt, ObjectProperties}; use object::{properties::ObjectProperties, ObjectExt};
/// A specialization of Reject in which the rejection is considered tentative. /// A specialization of Reject in which the rejection is considered tentative.
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]

View file

@ -21,9 +21,10 @@ use activitystreams_traits::{Activity, IntransitiveActivity, Object};
use super::{ use super::{
kind::TravelType, kind::TravelType,
properties::{ActivityExt, ActivityProperties, TravelProperties}, properties::{ActivityProperties, TravelProperties},
ActivityExt,
}; };
use object::properties::{ObjectExt, ObjectProperties}; use object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor is traveling to target from origin. /// Indicates that the actor is traveling to target from origin.
/// ///

View file

@ -21,9 +21,10 @@ use activitystreams_traits::{Activity, Object};
use super::{ use super::{
kind::UndoType, kind::UndoType,
properties::{ActivityExt, ActivityProperties, UndoProperties}, properties::{ActivityProperties, UndoProperties},
ActivityExt,
}; };
use object::properties::{ObjectExt, ObjectProperties}; use object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor is undoing the object. /// Indicates that the actor is undoing the object.
/// ///

View file

@ -21,9 +21,10 @@ use activitystreams_traits::{Activity, Object};
use super::{ use super::{
kind::UpdateType, kind::UpdateType,
properties::{ActivityExt, ActivityProperties, UpdateProperties}, properties::{ActivityProperties, UpdateProperties},
ActivityExt,
}; };
use object::properties::{ObjectExt, ObjectProperties}; use object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor has updated the object. /// Indicates that the actor has updated the object.
/// ///

View file

@ -21,9 +21,10 @@ use activitystreams_traits::{Activity, Object};
use super::{ use super::{
kind::ViewType, kind::ViewType,
properties::{ActivityExt, ActivityProperties, ViewProperties}, properties::{ActivityProperties, ViewProperties},
ActivityExt,
}; };
use object::properties::{ObjectExt, ObjectProperties}; use object::{properties::ObjectProperties, ObjectExt};
/// Indicates that the actor has viewed the object. /// Indicates that the actor has viewed the object.
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]

View file

@ -21,7 +21,7 @@
use activitystreams_traits::{Actor, Object}; use activitystreams_traits::{Actor, Object};
use object::properties::{ObjectExt, ObjectProperties}; use object::{properties::ObjectProperties, ObjectExt};
pub mod kind; pub mod kind;
use self::kind::*; use self::kind::*;

View file

@ -21,13 +21,23 @@
use activitystreams_traits::{Collection, CollectionPage, Object}; use activitystreams_traits::{Collection, CollectionPage, Object};
use object::properties::{ObjectExt, ObjectProperties}; use object::{properties::ObjectProperties, ObjectExt};
pub mod kind; pub mod kind;
pub mod properties; pub mod properties;
use self::kind::*; use self::kind::*;
use self::properties::*; use self::properties::*;
pub trait CollectionExt: Collection {
fn props(&self) -> &CollectionProperties;
fn props_mut(&mut self) -> &mut CollectionProperties;
}
pub trait CollectionPageExt: CollectionPage {
fn props(&self) -> &CollectionPageProperties;
fn props_mut(&mut self) -> &mut CollectionPageProperties;
}
/// The default `Collection` type. /// The default `Collection` type.
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -59,16 +59,6 @@
use activitystreams_traits::{Collection, CollectionPage, Link, Object}; use activitystreams_traits::{Collection, CollectionPage, Link, Object};
use serde_json; use serde_json;
pub trait CollectionExt {
fn props(&self) -> &CollectionProperties;
fn props_mut(&mut self) -> &mut CollectionProperties;
}
pub trait CollectionPageExt {
fn props(&self) -> &CollectionPageProperties;
fn props_mut(&mut self) -> &mut CollectionPageProperties;
}
/// `Collection` objects are a specialization of the base `Object` that serve as a container for /// `Collection` objects are a specialization of the base `Object` that serve as a container for
/// other `Objects` or `Links`. /// other `Objects` or `Links`.
/// ///

View file

@ -26,6 +26,11 @@ pub mod properties;
use self::kind::*; use self::kind::*;
use self::properties::*; use self::properties::*;
pub trait LinkExt: Link {
fn props(&self) -> &LinkProperties;
fn props_mut(&mut self) -> &mut LinkProperties;
}
/// A specialized Link that represents an @mention. /// A specialized Link that represents an @mention.
#[derive(Clone, Debug, Default, Deserialize, Serialize)] #[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -53,11 +53,6 @@ use activitystreams_traits::{Error, Link, Object, Result};
use mime; use mime;
use serde_json; use serde_json;
pub trait LinkExt {
fn props(&self) -> &LinkProperties;
fn props_mut(&mut self) -> &mut LinkProperties;
}
/// Define all the properties of the Object base type as described by the Activity Streams /// Define all the properties of the Object base type as described by the Activity Streams
/// vocabulary. /// vocabulary.
/// ///

View file

@ -26,6 +26,11 @@ pub mod properties;
use self::kind::*; use self::kind::*;
use self::properties::*; use self::properties::*;
pub trait ObjectExt: Object {
fn props(&self) -> &ObjectProperties;
fn props_mut(&mut self) -> &mut ObjectProperties;
}
/// Represents any kind of multi-paragraph written work. /// Represents any kind of multi-paragraph written work.
#[derive(Clone, Debug, Default, Deserialize, Serialize)] #[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View file

@ -56,11 +56,6 @@ use serde_json;
use object::Image; use object::Image;
pub trait ObjectExt {
fn props(&self) -> &ObjectProperties;
fn props_mut(&mut self) -> &mut ObjectProperties;
}
/// Alias chrono::DateTime<Utc> for use in derive macros /// Alias chrono::DateTime<Utc> for use in derive macros
pub type UtcTime = DateTime<Utc>; pub type UtcTime = DateTime<Utc>;

View file

@ -21,9 +21,7 @@
pub use activitystreams_traits::{Activity, IntransitiveActivity}; pub use activitystreams_traits::{Activity, IntransitiveActivity};
pub use activitystreams_types::activity::{ pub use activitystreams_types::activity::{
kind, kind, properties, AMove, Accept, ActivityExt, Add, Announce, Arrive, Block, Create, Delete,
properties::{self, ActivityExt}, Dislike, Flag, Follow, Ignore, Invite, Join, Leave, Like, Listen, Offer, Question, Read,
AMove, Accept, Add, Announce, Arrive, Block, Create, Delete, Dislike, Flag, Follow, Ignore, Reject, Remove, TentativeAccept, TentativeReject, Travel, Undo, Update, View,
Invite, Join, Leave, Like, Listen, Offer, Question, Read, Reject, Remove, TentativeAccept,
TentativeReject, Travel, Undo, Update, View,
}; };

View file

@ -21,7 +21,6 @@
pub use activitystreams_traits::{Collection, CollectionPage}; pub use activitystreams_traits::{Collection, CollectionPage};
pub use activitystreams_types::collection::{ pub use activitystreams_types::collection::{
kind, kind, properties, CollectionExt, CollectionPageExt, OrderedCollection, OrderedCollectionPage,
properties::{self, CollectionExt, CollectionPageExt}, UnorderedCollection, UnorderedCollectionPage,
OrderedCollection, OrderedCollectionPage, UnorderedCollection, UnorderedCollectionPage,
}; };

View file

@ -20,8 +20,4 @@
//! Link traits and types //! Link traits and types
pub use activitystreams_traits::Link; pub use activitystreams_traits::Link;
pub use activitystreams_types::link::{ pub use activitystreams_types::link::{kind, properties, LinkExt, Mention};
kind,
properties::{self, LinkExt},
Mention,
};

View file

@ -21,8 +21,6 @@
pub use activitystreams_traits::Object; pub use activitystreams_traits::Object;
pub use activitystreams_types::object::{ pub use activitystreams_types::object::{
kind, kind, properties, Article, Audio, Document, Event, Image, Note, ObjectExt, Page, Place,
properties::{self, ObjectExt}, Profile, Relationship, Tombstone, Video,
Article, Audio, Document, Event, Image, Note, Page, Place, Profile, Relationship, Tombstone,
Video,
}; };