activitystreams_types/collection/
mod.rs1use activitystreams_derive::Properties;
23use activitystreams_traits::{Collection, CollectionPage, Object};
24use serde_derive::{Deserialize, Serialize};
25
26use crate::object::{properties::ObjectProperties, ObjectExt};
27
28pub mod kind;
29pub mod properties;
30use self::kind::*;
31use self::properties::*;
32
33pub trait CollectionExt: Collection {
37 fn props(&self) -> &CollectionProperties;
38 fn props_mut(&mut self) -> &mut CollectionProperties;
39}
40
41pub trait CollectionPageExt: CollectionPage {
45 fn props(&self) -> &CollectionPageProperties;
46 fn props_mut(&mut self) -> &mut CollectionPageProperties;
47}
48
49#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
51#[serde(rename_all = "camelCase")]
52pub struct UnorderedCollection {
53 #[serde(rename = "type")]
54 #[serde(alias = "objectType")]
55 #[serde(alias = "verb")]
56 kind: CollectionType,
57
58 #[serde(flatten)]
60 pub object_props: ObjectProperties,
61
62 #[serde(flatten)]
64 pub collection_props: CollectionProperties,
65}
66
67impl Object for UnorderedCollection {}
68impl ObjectExt for UnorderedCollection {
69 fn props(&self) -> &ObjectProperties {
70 &self.object_props
71 }
72
73 fn props_mut(&mut self) -> &mut ObjectProperties {
74 &mut self.object_props
75 }
76}
77impl Collection for UnorderedCollection {}
78impl CollectionExt for UnorderedCollection {
79 fn props(&self) -> &CollectionProperties {
80 &self.collection_props
81 }
82
83 fn props_mut(&mut self) -> &mut CollectionProperties {
84 &mut self.collection_props
85 }
86}
87
88#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
91#[serde(rename_all = "camelCase")]
92pub struct OrderedCollection {
93 #[serde(rename = "type")]
94 #[serde(alias = "objectType")]
95 #[serde(alias = "verb")]
96 kind: OrderedCollectionType,
97
98 #[serde(flatten)]
100 pub object_props: ObjectProperties,
101
102 #[serde(flatten)]
104 pub collection_props: CollectionProperties,
105}
106
107impl Object for OrderedCollection {}
108impl ObjectExt for OrderedCollection {
109 fn props(&self) -> &ObjectProperties {
110 &self.object_props
111 }
112
113 fn props_mut(&mut self) -> &mut ObjectProperties {
114 &mut self.object_props
115 }
116}
117impl Collection for OrderedCollection {}
118impl CollectionExt for OrderedCollection {
119 fn props(&self) -> &CollectionProperties {
120 &self.collection_props
121 }
122
123 fn props_mut(&mut self) -> &mut CollectionProperties {
124 &mut self.collection_props
125 }
126}
127
128#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
130#[serde(rename_all = "camelCase")]
131pub struct UnorderedCollectionPage {
132 #[serde(rename = "type")]
133 #[serde(alias = "objectType")]
134 #[serde(alias = "verb")]
135 kind: CollectionPageType,
136
137 #[serde(flatten)]
139 pub object_props: ObjectProperties,
140
141 #[serde(flatten)]
143 pub collection_props: CollectionProperties,
144
145 #[serde(flatten)]
147 pub collection_page_props: CollectionPageProperties,
148}
149
150impl Object for UnorderedCollectionPage {}
151impl ObjectExt for UnorderedCollectionPage {
152 fn props(&self) -> &ObjectProperties {
153 &self.object_props
154 }
155
156 fn props_mut(&mut self) -> &mut ObjectProperties {
157 &mut self.object_props
158 }
159}
160impl Collection for UnorderedCollectionPage {}
161impl CollectionExt for UnorderedCollectionPage {
162 fn props(&self) -> &CollectionProperties {
163 &self.collection_props
164 }
165
166 fn props_mut(&mut self) -> &mut CollectionProperties {
167 &mut self.collection_props
168 }
169}
170impl CollectionPage for UnorderedCollectionPage {}
171impl CollectionPageExt for UnorderedCollectionPage {
172 fn props(&self) -> &CollectionPageProperties {
173 &self.collection_page_props
174 }
175
176 fn props_mut(&mut self) -> &mut CollectionPageProperties {
177 &mut self.collection_page_props
178 }
179}
180
181#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
183#[serde(rename_all = "camelCase")]
184pub struct OrderedCollectionPage {
185 #[serde(rename = "type")]
186 #[serde(alias = "objectType")]
187 #[serde(alias = "verb")]
188 kind: OrderedCollectionPageType,
189
190 #[serde(flatten)]
192 pub object_props: ObjectProperties,
193
194 #[serde(flatten)]
196 pub collection_props: CollectionProperties,
197
198 #[serde(flatten)]
200 pub collection_page_props: CollectionPageProperties,
201
202 #[serde(flatten)]
204 pub ordered_collection_page_props: OrderedCollectionPageProperties,
205}
206
207impl Object for OrderedCollectionPage {}
208impl ObjectExt for OrderedCollectionPage {
209 fn props(&self) -> &ObjectProperties {
210 &self.object_props
211 }
212
213 fn props_mut(&mut self) -> &mut ObjectProperties {
214 &mut self.object_props
215 }
216}
217impl Collection for OrderedCollectionPage {}
218impl CollectionExt for OrderedCollectionPage {
219 fn props(&self) -> &CollectionProperties {
220 &self.collection_props
221 }
222
223 fn props_mut(&mut self) -> &mut CollectionProperties {
224 &mut self.collection_props
225 }
226}
227impl CollectionPage for OrderedCollectionPage {}
228impl CollectionPageExt for OrderedCollectionPage {
229 fn props(&self) -> &CollectionPageProperties {
230 &self.collection_page_props
231 }
232
233 fn props_mut(&mut self) -> &mut CollectionPageProperties {
234 &mut self.collection_page_props
235 }
236}