From f17b2afb3b812c1babad1602f13c35977b8e7701 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Wed, 30 Oct 2024 09:40:24 +0100 Subject: Rename stream::activity types and structs. --- src/stream/activity.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/stream/activity.rs') diff --git a/src/stream/activity.rs b/src/stream/activity.rs index dd311d7..6020558 100644 --- a/src/stream/activity.rs +++ b/src/stream/activity.rs @@ -1,5 +1,5 @@ /** - * Representation of a stream item, as received from the zot api streams. + * Representation of an activity, as received from the zot api streams. * * SPDX-FileCopyrightText: 2023 Eilertsens Kodeknekkeri * SPDX-FileCopyrightText: 2023 Harald Eilertsen @@ -18,19 +18,19 @@ use uuid::Uuid; #[derive(Debug, Deserialize, PartialEq)] #[serde(rename_all="snake_case")] -pub enum StreamItemType { +pub enum ActivityType { Activity, } #[derive(Debug, Deserialize, PartialEq)] #[serde(rename_all="snake_case")] -pub enum StreamItemEncoding { +pub enum ActivityEncoding { Zot, } #[derive(Debug, Deserialize, PartialEq)] #[serde(rename_all="snake_case")] -pub enum StreamItemFlag { +pub enum ActivityFlag { Direct, Notshown, Private, @@ -41,10 +41,10 @@ pub enum StreamItemFlag { * Represents an item as returned by the stream API's. */ #[derive(Debug, Deserialize, PartialEq)] -pub struct StreamItem { +pub struct Activity { #[serde(rename="type")] - pub item_type: StreamItemType, - pub encoding: StreamItemEncoding, + pub item_type: ActivityType, + pub encoding: ActivityEncoding, pub uuid: Uuid, pub message_id: Url, @@ -72,11 +72,11 @@ pub struct StreamItem { pub author: Actor, pub signature: String, - pub flags: Option>, + pub flags: Option>, pub tags: Option>, } -impl StreamItem { +impl Activity { pub fn is_post(&self) -> bool { self.verb == Verb::Post } @@ -164,10 +164,10 @@ mod test { ] }"#; - let item: StreamItem = serde_json::from_str(&json).unwrap(); + let item: Activity = serde_json::from_str(&json).unwrap(); - assert_eq!(StreamItemType::Activity, item.item_type); - assert_eq!(StreamItemEncoding::Zot, item.encoding); + assert_eq!(ActivityType::Activity, item.item_type); + assert_eq!(ActivityEncoding::Zot, item.encoding); assert_eq!("2c102ec3-676b-4d84-b2b4-9141467a254f", item.uuid.to_string()); assert_eq!("https://example.com/item/2c102ec3-676b-4d84-b2b4-9141467a254f", item.message_id.to_string()); assert_eq!("https://example.com/item/2c102ec3-676b-4d84-b2b4-9141467a254f", item.message_top.to_string()); @@ -181,6 +181,6 @@ mod test { assert_eq!("2023-12-12 17:00:42", &item.edited.to_string()); assert_eq!("0000-00-00 00:00:00", &item.expires.to_string()); assert_eq!("2023-12-19 09:01:15", &item.commented.to_string()); - assert_eq!(StreamItemFlag::ThreadParent, item.flags.as_ref().unwrap()[0]); + assert_eq!(ActivityFlag::ThreadParent, item.flags.as_ref().unwrap()[0]); } } -- cgit v1.2.3