From d4e7c4b59b2d3c2fb4fceb5e6c7b7256cb62e8e6 Mon Sep 17 00:00:00 2001 From: "D. Scott Boggs" Date: Mon, 9 Jan 2023 07:53:58 -0500 Subject: [PATCH] Add ID type for relationships --- entities/src/relationship.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/entities/src/relationship.rs b/entities/src/relationship.rs index 44f89b3..b0357e5 100644 --- a/entities/src/relationship.rs +++ b/entities/src/relationship.rs @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] pub struct Relationship { /// Target account id - pub id: String, + pub id: RelationshipId, /// Whether the application client follows the account. pub following: bool, /// Whether the account follows the application client. @@ -31,3 +31,14 @@ pub struct Relationship { /// making calls to pleroma or mastodon<2.5.0 instances pub endorsed: Option, } + +/// Wrapper type for a relationship ID string +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[serde(transparent)] +pub struct RelationshipId(String); + +impl AsRef for RelationshipId { + fn as_ref(&self) -> &str { + &self.0 + } +}