activitystreams_types/activity/
undo.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::UndoType,
26    properties::{ActivityProperties, UndoProperties},
27    ActivityExt,
28};
29use crate::object::{properties::ObjectProperties, ObjectExt};
30
31/// Indicates that the actor is undoing the object.
32///
33/// In most cases, the object will be an Activity describing some previously performed action (for
34/// instance, a person may have previously "liked" an article but, for whatever reason, might
35/// choose to undo that like at some later point in time).
36///
37/// The target and origin typically have no defined meaning.
38#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
39#[serde(rename_all = "camelCase")]
40pub struct Undo {
41    #[serde(rename = "type")]
42    #[serde(alias = "objectType")]
43    #[serde(alias = "verb")]
44    pub kind: UndoType,
45
46    /// Adds all valid undo properties to this struct
47    #[serde(flatten)]
48    pub undo_props: UndoProperties,
49
50    /// Adds all valid object properties to this struct
51    #[serde(flatten)]
52    pub object_props: ObjectProperties,
53
54    /// Adds all valid activity properties to this struct
55    #[serde(flatten)]
56    pub activity_props: ActivityProperties,
57}
58
59impl Object for Undo {}
60impl ObjectExt for Undo {
61    fn props(&self) -> &ObjectProperties {
62        &self.object_props
63    }
64
65    fn props_mut(&mut self) -> &mut ObjectProperties {
66        &mut self.object_props
67    }
68}
69impl Activity for Undo {}
70impl ActivityExt for Undo {
71    fn props(&self) -> &ActivityProperties {
72        &self.activity_props
73    }
74
75    fn props_mut(&mut self) -> &mut ActivityProperties {
76        &mut self.activity_props
77    }
78}