summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2022-12-29 22:00:09 +0100
committerScott Boggs <dscottboggs@gmail.com>2023-01-09 09:03:21 -0500
commit97ae0973c31dd904a10387e4a18766e22bf6df8a (patch)
tree2fbf93b0e435b9b6c89a533901af6832ae568c53
parent10ec4dc81f18ffeab22f87ca6ddc7cffe96db7ce (diff)
Wrap status id in helper type
This wrapper type ensures that the status id cannot accidentially be compared to some other string that represents something entirely else. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--entities/src/status.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/entities/src/status.rs b/entities/src/status.rs
index eddda74..dd0cf84 100644
--- a/entities/src/status.rs
+++ b/entities/src/status.rs
@@ -9,7 +9,7 @@ use time::{serde::iso8601, OffsetDateTime};
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct Status {
/// The ID of the status.
- pub id: String,
+ pub id: StatusId,
/// A Fediverse-unique resource ID.
pub uri: String,
/// URL to the status page (can be remote)
@@ -65,6 +65,17 @@ pub struct Status {
pub pinned: Option<bool>,
}
+/// Wrapper type for a status ID string
+#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
+#[serde(transparent)]
+pub struct StatusId(String);
+
+impl AsRef<str> for StatusId {
+ fn as_ref(&self) -> &str {
+ &self.0
+ }
+}
+
/// A mention of another user.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct Mention {