diff --git a/Cargo.toml b/Cargo.toml index af7b27e..6e84390 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "activitystreams" description = "A set of core types and traits for activitystreams data" -version = "0.7.0-alpha.2" +version = "0.7.0-alpha.3" license = "GPL-3.0" authors = ["asonix "] repository = "https://git.asonix.dog/Aardwolf/activitystreams" diff --git a/README.md b/README.md index 8e231db..50e30e7 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ _A set of Traits and Types that make up the ActivityStreams and ActivityPub spec First, add ActivityStreams to your dependencies ```toml [dependencies] -activitystreams = "0.7.0-alpha.2" +activitystreams = "0.7.0-alpha.3" ``` ### Types diff --git a/activitystreams-ext/Cargo.toml b/activitystreams-ext/Cargo.toml index 9615fb5..b555392 100644 --- a/activitystreams-ext/Cargo.toml +++ b/activitystreams-ext/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "activitystreams-ext" description = "Extension types for the ActivityStreams crate" -version = "0.1.0-alpha.0" +version = "0.1.0-alpha.1" license = "GPL-3.0" authors = ["asonix "] repository = "https://git.asonix.dog/Aardwolf/activitystreams" @@ -13,7 +13,7 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -activitystreams = { version = "0.7.0-alpha.0", path = ".." } +activitystreams = { version = "0.7.0-alpha.3", path = ".." } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/activitystreams-ext/README.md b/activitystreams-ext/README.md index b5bc2fd..0bfa607 100644 --- a/activitystreams-ext/README.md +++ b/activitystreams-ext/README.md @@ -11,8 +11,8 @@ _This crate provides Ext1, Ext2, Ext3, and Ext4 for adding extensions to Activit First, add ActivityStreams to your dependencies ```toml [dependencies] -activitystreams = "0.7.0-alpha.0" -activitystreams-ext = "0.1.0-alpha.0" +activitystreams = "0.7.0-alpha.3" +activitystreams-ext = "0.1.0-alpha.1" ``` For an example, we'll implement a PublicKey extension and demonstrate usage with Ext1 diff --git a/activitystreams-ext/src/lib.rs b/activitystreams-ext/src/lib.rs index f4bd607..baa9623 100644 --- a/activitystreams-ext/src/lib.rs +++ b/activitystreams-ext/src/lib.rs @@ -11,8 +11,8 @@ //! First, add ActivityStreams to your dependencies //! ```toml //! [dependencies] -//! activitystreams = "0.7.0-alpha.0" -//! activitystreams-ext = "0.1.0-alpha.0" +//! activitystreams = "0.7.0-alpha.3" +//! activitystreams-ext = "0.1.0-alpha.1" //! ``` //! //! For an example, we'll implement a PublicKey extension and demonstrate usage with Ext1 @@ -185,6 +185,10 @@ impl Ext1 { Ext1 { inner, ext_one } } + pub fn into_parts(self) -> (Inner, A) { + (self.inner, self.ext_one) + } + pub fn extend(self, ext_two: B) -> Ext2 { Ext2 { inner: self.inner, @@ -203,6 +207,10 @@ impl Ext2 { } } + pub fn into_parts(self) -> (Inner, A, B) { + (self.inner, self.ext_one, self.ext_two) + } + pub fn extend(self, ext_three: C) -> Ext3 { Ext3 { inner: self.inner, @@ -223,6 +231,10 @@ impl Ext3 { } } + pub fn into_parts(self) -> (Inner, A, B, C) { + (self.inner, self.ext_one, self.ext_two, self.ext_three) + } + pub fn extend(self, ext_four: D) -> Ext4 { Ext4 { inner: self.inner, @@ -234,6 +246,28 @@ impl Ext3 { } } +impl Ext4 { + pub fn new(inner: Inner, ext_one: A, ext_two: B, ext_three: C, ext_four: D) -> Self { + Ext4 { + inner, + ext_one, + ext_two, + ext_three, + ext_four, + } + } + + pub fn into_parts(self) -> (Inner, A, B, C, D) { + ( + self.inner, + self.ext_one, + self.ext_two, + self.ext_three, + self.ext_four, + ) + } +} + impl Extends for Ext1 where Inner: Extends + UnparsedMut, diff --git a/src/activity.rs b/src/activity.rs index f581624..1b59cae 100644 --- a/src/activity.rs +++ b/src/activity.rs @@ -2024,6 +2024,19 @@ impl ActorAndObject { } } + /// Deconstruct the ActorAndObject into its parts + /// + /// ```rust + /// use activitystreams::activity::ActorAndObject; + /// + /// let activity = ActorAndObject::::new(vec![], vec![]); + /// + /// let (actor, object, activity) = activity.into_parts(); + /// ``` + pub fn into_parts(self) -> (OneOrMany, OneOrMany, Activity) { + (self.actor, self.object, self.inner) + } + fn extending(object: Object) -> Result { let mut inner = Activity::extending(object)?; @@ -2070,6 +2083,19 @@ impl Arrive { } } + /// Deconstruct the Arrive into its parts + /// + /// ```rust + /// use activitystreams::activity::Arrive; + /// + /// let activity = Arrive::new(vec![], vec![]); + /// + /// let (actor, origin, activity) = activity.into_parts(); + /// ``` + pub fn into_parts(self) -> (OneOrMany, OneOrMany, Activity) { + (self.actor, self.origin, self.inner) + } + fn extending(object: Object) -> Result { let mut inner = Activity::extending(object)?; @@ -2118,6 +2144,26 @@ impl Invite { } } + /// Deconstruct the Invite into its parts + /// + /// ```rust + /// use activitystreams::activity::Invite; + /// + /// let activity = Invite::new(vec![], vec![], vec![]); + /// + /// let (actor, object, target, activity) = activity.into_parts(); + /// ``` + pub fn into_parts( + self, + ) -> ( + OneOrMany, + OneOrMany, + OneOrMany, + Activity, + ) { + (self.actor, self.object, self.target, self.inner) + } + fn extending(object: Object) -> Result { let mut inner = Activity::extending(object)?; @@ -2171,6 +2217,26 @@ impl Delete { } } + /// Deconstruct the Delete into its parts + /// + /// ```rust + /// use activitystreams::activity::Delete; + /// + /// let activity = Delete::new(vec![], vec![]); + /// + /// let (actor, object, origin, activity) = activity.into_parts(); + /// ``` + pub fn into_parts( + self, + ) -> ( + OneOrMany, + OneOrMany, + Option>, + Activity, + ) { + (self.actor, self.object, self.origin, self.inner) + } + fn extending(object: Object) -> Result { let mut inner = Activity::extending(object)?; @@ -2229,6 +2295,33 @@ impl ActorAndObjectOptOriginAndTarget { } } + /// Deconstruct the ActorAndObjectOptOriginAndTarget into its parts + /// + /// ```rust + /// use activitystreams::activity::ActorAndObjectOptOriginAndTarget; + /// + /// let activity = ActorAndObjectOptOriginAndTarget::::new(vec![], vec![]); + /// + /// let (actor, object, origin, target, activity) = activity.into_parts(); + /// ``` + pub fn into_parts( + self, + ) -> ( + OneOrMany, + OneOrMany, + Option>, + Option>, + Activity, + ) { + ( + self.actor, + self.object, + self.origin, + self.target, + self.inner, + ) + } + fn extending(object: Object) -> Result { let mut inner = Activity::extending(object)?; @@ -2290,6 +2383,26 @@ impl ActorAndObjectOptTarget { } } + /// Deconstruct the ActorAndObjectOptTarget into its parts + /// + /// ```rust + /// use activitystreams::activity::ActorAndObjectOptTarget; + /// + /// let activity = ActorAndObjectOptTarget::::new(vec![], vec![]); + /// + /// let (actor, object, target, activity) = activity.into_parts(); + /// ``` + pub fn into_parts( + self, + ) -> ( + OneOrMany, + OneOrMany, + Option>, + Activity, + ) { + (self.actor, self.object, self.target, self.inner) + } + fn extending(object: Object) -> Result { let mut inner = Activity::extending(object)?; @@ -2342,6 +2455,26 @@ impl Travel { } } + /// Deconstruct the Travel into its parts + /// + /// ```rust + /// use activitystreams::activity::Travel; + /// + /// let activity = Travel::new(vec![]); + /// + /// let (actor, origin, target, activity) = activity.into_parts(); + /// ``` + pub fn into_parts( + self, + ) -> ( + OneOrMany, + Option>, + Option>, + Activity, + ) { + (self.actor, self.origin, self.target, self.inner) + } + fn extending(object: Object) -> Result { let mut inner = Activity::extending(object)?; @@ -2390,6 +2523,25 @@ impl Question { } } + /// Deconstruct the Question into its parts + /// + /// ```rust + /// use activitystreams::activity::Question; + /// + /// let activity = Question::new(); + /// + /// let (one_of, any_of, activity) = activity.into_parts(); + /// ``` + pub fn into_parts( + self, + ) -> ( + Option>, + Option>, + Activity, + ) { + (self.one_of, self.any_of, self.inner) + } + fn extending(object: Object) -> Result { let mut inner = Activity::extending(object)?; diff --git a/src/actor.rs b/src/actor.rs index bb0eea6..f7eeef8 100644 --- a/src/actor.rs +++ b/src/actor.rs @@ -1287,6 +1287,54 @@ impl ApActor { } } + /// Deconstruct the ApActor into its parts + /// + /// ```rust + /// # fn main() -> Result<(), anyhow::Error> { + /// use activitystreams::{actor::{ApActor, Person}, uri}; + /// + /// let actor = ApActor::new(uri!("https://inbox.url"), Person::new()); + /// + /// let ( + /// inbox, + /// outbox, + /// following, + /// followers, + /// liked, + /// streams, + /// preferred_username, + /// endpoints, + /// person, + /// ) = actor.into_parts(); + /// # Ok(()) + /// # } + /// ``` + pub fn into_parts( + self, + ) -> ( + Url, + Option, + Option, + Option, + Option, + Option>, + Option, + Option>, + Inner, + ) { + ( + self.inbox, + self.outbox, + self.following, + self.followers, + self.liked, + self.streams, + self.preferred_username, + self.endpoints, + self.inner, + ) + } + fn extending(mut inner: Inner) -> Result where Inner: UnparsedMut + markers::Actor, diff --git a/src/lib.rs b/src/lib.rs index f050c97..fe0b9ca 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,7 +11,7 @@ //! First, add ActivityStreams to your dependencies //! ```toml //! [dependencies] -//! activitystreams = "0.7.0-alpha.2" +//! activitystreams = "0.7.0-alpha.3" //! ``` //! //! ### Types @@ -293,7 +293,7 @@ //! //! You should have received a copy of the GNU General Public License along with ActivityStreams. If not, see [http://www.gnu.org/licenses/](http://www.gnu.org/licenses/). -#![doc(html_root_url = "https://docs.rs/activitystreams/0.7.0-alpha.2/activitystreams")] +#![doc(html_root_url = "https://docs.rs/activitystreams/0.7.0-alpha.3/activitystreams")] pub mod activity; pub mod actor; diff --git a/src/object.rs b/src/object.rs index 6157a30..9831e16 100644 --- a/src/object.rs +++ b/src/object.rs @@ -4846,6 +4846,33 @@ impl ApObject { } } + /// Deconstruct the ApObject into its parts + /// + /// ```rust + /// use activitystreams::object::{ApObject, Image}; + /// + /// let object = ApObject::new(Image::new()); + /// + /// let (shares, likes, source, upload_media, image) = object.into_parts(); + /// ``` + pub fn into_parts( + self, + ) -> ( + Option, + Option, + Option, + Option>, + Inner, + ) { + ( + self.shares, + self.likes, + self.source, + self.upload_media, + self.inner, + ) + } + fn extending(mut inner: Inner) -> Result where Inner: UnparsedMut + markers::Object,