diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2024-01-12 18:59:05 +0100 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2024-01-12 18:59:05 +0100 |
commit | 316c62b8ddce3315cca0a9ecf35c551e8013160e (patch) | |
tree | 2a14ab0ecf8ef18c9fdc52ca9acdade298d1b88b /src/stream/streamitem.rs | |
parent | be04fb276aa4777f5477c579fc82f1cef9b18d65 (diff) | |
download | rust-zotapi-316c62b8ddce3315cca0a9ecf35c551e8013160e.tar.gz rust-zotapi-316c62b8ddce3315cca0a9ecf35c551e8013160e.tar.bz2 rust-zotapi-316c62b8ddce3315cca0a9ecf35c551e8013160e.zip |
Refactor stream API, move StreamItem and Verb to modules.
Diffstat (limited to 'src/stream/streamitem.rs')
-rw-r--r-- | src/stream/streamitem.rs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/stream/streamitem.rs b/src/stream/streamitem.rs new file mode 100644 index 0000000..343ed28 --- /dev/null +++ b/src/stream/streamitem.rs @@ -0,0 +1,46 @@ +/** + * Representation of a stream item, as received from the zot api streams. + * + * SPDX-FileCopyrightText: 2023 Eilertsens Kodeknekkeri + * SPDX-FileCopyrightText: 2023 Harald Eilertsen <haraldei@anduin.net> + * + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +use super::verb::Verb; + +use serde::Deserialize; + +#[derive(Debug, Deserialize, PartialEq)] +pub enum StreamItemType { + #[serde(rename="activity")] + Activity, +} + +#[derive(Debug, Deserialize, PartialEq)] +pub enum StreamItemEncoding { + #[serde(rename="zot")] + Zot, +} + +/** + * Represents an item as returned by the stream API's. + */ +#[derive(Debug, Deserialize, PartialEq)] +pub struct StreamItem { + #[serde(rename="type")] + pub item_type: StreamItemType, + pub encoding: StreamItemEncoding, + + pub verb: Verb, + + pub title: String, + pub summary: String, + pub body: String, +} + +impl StreamItem { + pub fn is_post(&self) -> bool { + self.verb == Verb::Post + } +} |