From c5f199b46062ae13b44d1cd9af4d254e27d1bde2 Mon Sep 17 00:00:00 2001 From: "D. Scott Boggs" Date: Mon, 9 Jan 2023 07:53:25 -0500 Subject: [PATCH] Add ID type for filters --- entities/src/filter.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/entities/src/filter.rs b/entities/src/filter.rs index e844b42..dcdcfe1 100644 --- a/entities/src/filter.rs +++ b/entities/src/filter.rs @@ -35,7 +35,7 @@ use time::{serde::iso8601, OffsetDateTime}; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct Filter { /// The ID of the Filter in the database. - pub id: String, + pub id: FilterId, /// A title given by the user to name the filter. pub title: String, /// The contexts in which the filter should be applied. @@ -51,6 +51,17 @@ pub struct Filter { pub statuses: Vec, } +/// Wrapper type for a filter ID string +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[serde(transparent)] +pub struct FilterId(String); + +impl AsRef for FilterId { + fn as_ref(&self) -> &str { + &self.0 + } +} + /// Represents the various types of Filter contexts #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "lowercase")]