2018-05-12 20:14:43 +00:00
|
|
|
/*
|
2018-05-14 03:24:41 +00:00
|
|
|
* This file is part of ActivityStreams Types.
|
2018-05-12 20:14:43 +00:00
|
|
|
*
|
|
|
|
* Copyright © 2018 Riley Trautman
|
|
|
|
*
|
2018-05-14 03:24:41 +00:00
|
|
|
* ActivityStreams Types is free software: you can redistribute it and/or modify
|
2018-05-12 20:14:43 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2018-05-14 03:24:41 +00:00
|
|
|
* ActivityStreams Types is distributed in the hope that it will be useful,
|
2018-05-12 20:14:43 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2018-05-14 03:24:41 +00:00
|
|
|
* along with ActivityStreams Types. If not, see <http://www.gnu.org/licenses/>.
|
2018-05-12 20:14:43 +00:00
|
|
|
*/
|
|
|
|
|
2018-05-14 03:24:41 +00:00
|
|
|
use activitystreams_traits::{Activity, IntransitiveActivity, Link, Object};
|
2018-05-12 05:31:33 +00:00
|
|
|
use serde_json;
|
|
|
|
|
2018-05-14 03:24:41 +00:00
|
|
|
use super::{kind::QuestionType, properties::ActivityProperties};
|
|
|
|
use object::properties::ObjectProperties;
|
2018-05-12 05:31:33 +00:00
|
|
|
|
2018-05-14 06:18:12 +00:00
|
|
|
/// Represents a question being asked.
|
|
|
|
///
|
|
|
|
/// Question objects are an extension of IntransitiveActivity. That is, the Question object is an
|
|
|
|
/// Activity, but the direct object is the question itself and therefore it would not contain an
|
|
|
|
/// object property.
|
|
|
|
///
|
|
|
|
/// Either of the anyOf and oneOf properties MAY be used to express possible answers, but a
|
|
|
|
/// Question object MUST NOT have both properties.
|
2018-05-13 20:58:47 +00:00
|
|
|
#[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)]
|
2018-05-12 05:31:33 +00:00
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
pub struct Question {
|
|
|
|
#[serde(rename = "type")]
|
2018-05-14 06:18:12 +00:00
|
|
|
pub kind: QuestionType,
|
2018-05-12 05:31:33 +00:00
|
|
|
|
2018-05-14 06:18:12 +00:00
|
|
|
/// Identifies an exclusive option for a Question.
|
|
|
|
///
|
|
|
|
/// Use of `one_of` implies that the Question can have only a single answer. To indicate that a
|
|
|
|
/// `Question` can have multiple answers, use `any_of`.
|
|
|
|
///
|
|
|
|
/// - Range: `Object` | `Link`
|
|
|
|
/// - Functional: false
|
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2018-05-12 19:35:10 +00:00
|
|
|
#[activitystreams(ab(Object, Link))]
|
2018-05-14 06:18:12 +00:00
|
|
|
pub one_of: Option<serde_json::Value>,
|
2018-05-12 05:31:33 +00:00
|
|
|
|
2018-05-14 06:18:12 +00:00
|
|
|
/// Identifies an inclusive option for a Question.
|
|
|
|
///
|
|
|
|
/// Use of `any_of` implies that the Question can have multiple answers. To indicate that a
|
|
|
|
/// `Question` can have only one answer, use `one_of`.
|
|
|
|
///
|
|
|
|
/// - Range: `Object` | `Link`
|
|
|
|
/// - Functional: false
|
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2018-05-12 19:35:10 +00:00
|
|
|
#[activitystreams(ab(Object, Link))]
|
2018-05-14 06:18:12 +00:00
|
|
|
pub any_of: Option<serde_json::Value>,
|
2018-05-12 05:31:33 +00:00
|
|
|
|
2018-05-14 06:18:12 +00:00
|
|
|
/// Adds all valid object properties to this struct
|
2018-05-12 19:35:10 +00:00
|
|
|
#[serde(flatten)]
|
|
|
|
pub object_props: ObjectProperties,
|
2018-05-12 05:31:33 +00:00
|
|
|
|
2018-05-14 06:18:12 +00:00
|
|
|
/// Adds all valid activity properties to this struct
|
2018-05-12 19:35:10 +00:00
|
|
|
#[serde(flatten)]
|
|
|
|
pub activity_props: ActivityProperties,
|
2018-05-12 05:31:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Object for Question {}
|
|
|
|
impl Activity for Question {}
|
|
|
|
impl IntransitiveActivity for Question {}
|