activitystreams_types/activity/
travel.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, IntransitiveActivity, Object};
22use serde_derive::{Deserialize, Serialize};
23
24use super::{
25    kind::TravelType,
26    properties::{ActivityProperties, TravelProperties},
27    ActivityExt,
28};
29use crate::object::{properties::ObjectProperties, ObjectExt};
30
31/// Indicates that the actor is traveling to target from origin.
32///
33/// Travel is an IntransitiveObject whose actor specifies the direct object. If the target or
34/// origin are not specified, either can be determined by context.
35#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
36#[serde(rename_all = "camelCase")]
37pub struct Travel {
38    #[serde(rename = "type")]
39    #[serde(alias = "objectType")]
40    #[serde(alias = "verb")]
41    pub kind: TravelType,
42
43    /// Adds all valid travel properties to this struct
44    #[serde(flatten)]
45    pub travel_props: TravelProperties,
46
47    /// Adds all valid object properties to this struct
48    #[serde(flatten)]
49    pub object_props: ObjectProperties,
50
51    /// Adds all valid activity properties to this struct
52    #[serde(flatten)]
53    pub activity_props: ActivityProperties,
54}
55
56impl Object for Travel {}
57impl ObjectExt for Travel {
58    fn props(&self) -> &ObjectProperties {
59        &self.object_props
60    }
61
62    fn props_mut(&mut self) -> &mut ObjectProperties {
63        &mut self.object_props
64    }
65}
66impl Activity for Travel {}
67impl ActivityExt for Travel {
68    fn props(&self) -> &ActivityProperties {
69        &self.activity_props
70    }
71
72    fn props_mut(&mut self) -> &mut ActivityProperties {
73        &mut self.activity_props
74    }
75}
76impl IntransitiveActivity for Travel {}