activitystreams_types/actor/
mod.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
20//! Namespace for Actor types
21
22use activitystreams_traits::{Actor, Object};
23use serde_derive::{Deserialize, Serialize};
24
25use crate::object::{properties::ObjectProperties, ObjectExt};
26
27pub mod kind;
28use self::kind::*;
29
30/// Describes a software application.
31#[derive(Clone, Debug, Default, Deserialize, Serialize)]
32#[serde(rename_all = "camelCase")]
33pub struct Application {
34    #[serde(rename = "type")]
35    #[serde(alias = "objectType")]
36    #[serde(alias = "verb")]
37    kind: ApplicationType,
38
39    /// Adds all valid object properties to this struct
40    #[serde(flatten)]
41    pub object_props: ObjectProperties,
42}
43
44impl Object for Application {}
45impl ObjectExt for Application {
46    fn props(&self) -> &ObjectProperties {
47        &self.object_props
48    }
49
50    fn props_mut(&mut self) -> &mut ObjectProperties {
51        &mut self.object_props
52    }
53}
54impl Actor for Application {}
55
56/// Represents a formal or informal collective of Actors.
57#[derive(Clone, Debug, Default, Deserialize, Serialize)]
58#[serde(rename_all = "camelCase")]
59pub struct Group {
60    #[serde(rename = "type")]
61    #[serde(alias = "objectType")]
62    #[serde(alias = "verb")]
63    kind: GroupType,
64
65    /// Adds all valid object properties to this struct
66    #[serde(flatten)]
67    pub object_props: ObjectProperties,
68}
69
70impl Object for Group {}
71impl ObjectExt for Group {
72    fn props(&self) -> &ObjectProperties {
73        &self.object_props
74    }
75
76    fn props_mut(&mut self) -> &mut ObjectProperties {
77        &mut self.object_props
78    }
79}
80impl Actor for Group {}
81
82/// Represents an organization.
83#[derive(Clone, Debug, Default, Deserialize, Serialize)]
84#[serde(rename_all = "camelCase")]
85pub struct Organization {
86    #[serde(rename = "type")]
87    #[serde(alias = "objectType")]
88    #[serde(alias = "verb")]
89    kind: OrganizationType,
90
91    /// Adds all valid object properties to this struct
92    #[serde(flatten)]
93    pub object_props: ObjectProperties,
94}
95
96impl Object for Organization {}
97impl ObjectExt for Organization {
98    fn props(&self) -> &ObjectProperties {
99        &self.object_props
100    }
101
102    fn props_mut(&mut self) -> &mut ObjectProperties {
103        &mut self.object_props
104    }
105}
106impl Actor for Organization {}
107
108/// Represents an individual person.
109#[derive(Clone, Debug, Default, Deserialize, Serialize)]
110#[serde(rename_all = "camelCase")]
111pub struct Person {
112    #[serde(rename = "type")]
113    #[serde(alias = "objectType")]
114    #[serde(alias = "verb")]
115    kind: PersonType,
116
117    /// Adds all valid object properties to this struct
118    #[serde(flatten)]
119    pub object_props: ObjectProperties,
120}
121
122impl Object for Person {}
123impl ObjectExt for Person {
124    fn props(&self) -> &ObjectProperties {
125        &self.object_props
126    }
127
128    fn props_mut(&mut self) -> &mut ObjectProperties {
129        &mut self.object_props
130    }
131}
132impl Actor for Person {}
133
134/// Represents a service of any kind.
135#[derive(Clone, Debug, Default, Deserialize, Serialize)]
136#[serde(rename_all = "camelCase")]
137pub struct Service {
138    #[serde(rename = "type")]
139    #[serde(alias = "objectType")]
140    #[serde(alias = "verb")]
141    kind: ServiceType,
142
143    /// Adds all valid object properties to this struct
144    #[serde(flatten)]
145    pub object_props: ObjectProperties,
146}
147
148impl Object for Service {}
149impl ObjectExt for Service {
150    fn props(&self) -> &ObjectProperties {
151        &self.object_props
152    }
153
154    fn props_mut(&mut self) -> &mut ObjectProperties {
155        &mut self.object_props
156    }
157}
158impl Actor for Service {}