activitystreams/collection/mod.rs
1/*
2 * This file is part of ActivityStreams.
3 *
4 * Copyright © 2020 Riley Trautman
5 *
6 * ActivityStreams is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ActivityStreams is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with ActivityStreams.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20//! Namespace for Collection types
21
22#[cfg(feature = "kinds")]
23pub mod kind;
24#[cfg(feature = "types")]
25pub mod properties;
26#[cfg(feature = "types")]
27mod types;
28
29#[cfg(feature = "types")]
30pub use self::types::{
31    OrderedCollection, OrderedCollectionPage, UnorderedCollection, UnorderedCollectionPage,
32};
33
34use crate::object::Object;
35
36/// A Collection is a subtype of `Object` that represents ordered or unordered sets of `Object` or
37/// `Link` instances.
38///
39/// The items within a Collection can be ordered or unordered. The OrderedCollection type MAY be
40/// used to identify a Collection whose items are always ordered. In the JSON serialization, the
41/// unordered items of a Collection are represented using the items property while ordered items
42/// are represented using the orderedItems property.
43///
44/// `UnorderedCollection` and `OrderedCollection` types are provided by the `activitystreams-types`
45/// crate.
46#[cfg_attr(feature = "derive", crate::wrapper_type)]
47pub trait Collection: Object {}
48
49/// Used to represent distinct subsets of items from a Collection.
50///
51/// A `Collection` can contain a large number of items. Often, it becomes impractical for an
52/// implementation to serialize every item contained by a `Collection` using the items (or
53/// `ordered_items`) property alone. In such cases, the items within a `Collection` can be divided
54/// into distinct subsets or "pages". A page is identified using the `CollectionPage` type.
55///
56/// `UnorderedCollectionPage` and `OrderedCollectionPage` types are provied by the
57/// `activitystreams-types` crate.
58#[cfg_attr(feature = "derive", crate::wrapper_type)]
59pub trait CollectionPage: Collection {}