activitystreams_types/activity/
invite.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::InviteType,
26    properties::{ActivityProperties, InviteProperties},
27    ActivityExt,
28};
29use crate::object::{properties::ObjectProperties, ObjectExt};
30
31/// A specialization of Offer in which the actor is extending an invitation for the object to the
32/// target.
33#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
34#[serde(rename_all = "camelCase")]
35pub struct Invite {
36    #[serde(rename = "type")]
37    #[serde(alias = "objectType")]
38    #[serde(alias = "verb")]
39    pub kind: InviteType,
40
41    /// Adds all valid invite properties to this struct
42    #[serde(flatten)]
43    pub invite_props: InviteProperties,
44
45    /// Adds all valid object properties to this struct
46    #[serde(flatten)]
47    pub object_props: ObjectProperties,
48
49    /// Adds all valid activity properties to this struct
50    #[serde(flatten)]
51    pub activity_props: ActivityProperties,
52}
53
54impl Object for Invite {}
55impl ObjectExt for Invite {
56    fn props(&self) -> &ObjectProperties {
57        &self.object_props
58    }
59
60    fn props_mut(&mut self) -> &mut ObjectProperties {
61        &mut self.object_props
62    }
63}
64impl Activity for Invite {}
65impl ActivityExt for Invite {
66    fn props(&self) -> &ActivityProperties {
67        &self.activity_props
68    }
69
70    fn props_mut(&mut self) -> &mut ActivityProperties {
71        &mut self.activity_props
72    }
73}