activitystreams_types/activity/
follow.rs

1/*
2 * This file is part of ActivityStreams Types.
3 *
4 * Copyright © 2018 Riley Trautman
5 *
6 * ActivityStreams Types 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 Types 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 Types.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20use activitystreams_derive::Properties;
21use activitystreams_traits::{Activity, Object};
22use serde_derive::{Deserialize, Serialize};
23
24use super::{
25    kind::FollowType,
26    properties::{ActivityProperties, FollowProperties},
27    ActivityExt,
28};
29use crate::object::{properties::ObjectProperties, ObjectExt};
30
31/// Indicates that the actor is "following" the object.
32///
33/// Following is defined in the sense typically used within Social systems in which the actor is
34/// interested in any activity performed by or on the object. The target and origin typically have
35/// no defined meaning.
36#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
37#[serde(rename_all = "camelCase")]
38pub struct Follow {
39    #[serde(rename = "type")]
40    #[serde(alias = "objectType")]
41    #[serde(alias = "verb")]
42    pub kind: FollowType,
43
44    /// Adds all valid follow properties to this struct
45    #[serde(flatten)]
46    pub follow_props: FollowProperties,
47
48    /// Adds all valid object properties to this struct
49    #[serde(flatten)]
50    pub object_props: ObjectProperties,
51
52    /// Adds all valid activity properties to this struct
53    #[serde(flatten)]
54    pub activity_props: ActivityProperties,
55}
56
57impl Object for Follow {}
58impl ObjectExt for Follow {
59    fn props(&self) -> &ObjectProperties {
60        &self.object_props
61    }
62
63    fn props_mut(&mut self) -> &mut ObjectProperties {
64        &mut self.object_props
65    }
66}
67impl Activity for Follow {}
68impl ActivityExt for Follow {
69    fn props(&self) -> &ActivityProperties {
70        &self.activity_props
71    }
72
73    fn props_mut(&mut self) -> &mut ActivityProperties {
74        &mut self.activity_props
75    }
76}