diff options
author | D. Scott Boggs <scott@tams.tech> | 2023-01-09 08:25:10 -0500 |
---|---|---|
committer | Scott Boggs <dscottboggs@gmail.com> | 2023-01-09 09:03:21 -0500 |
commit | 6d8a9d6194fd987645f2cf4a6cb77c61206c8a97 (patch) | |
tree | 36e402acc9c2dac1565a63606c23662e8e2bab85 | |
parent | 6e044c3f3505f57df1c4a295df6939eac43371b3 (diff) |
Add List ID type
-rw-r--r-- | entities/src/list.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/entities/src/list.rs b/entities/src/list.rs index 825db14..f5639f4 100644 --- a/entities/src/list.rs +++ b/entities/src/list.rs @@ -3,6 +3,23 @@ use serde::{Deserialize, Serialize}; /// Used for ser/de of list resources #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] pub struct List { - id: String, + id: ListId, title: String, } + +/// Wrapper type for a list ID string +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[serde(transparent)] +pub struct ListId(String); + +impl AsRef<str> for ListId { + fn as_ref(&self) -> &str { + &self.0 + } +} + +impl ListId { + pub fn new(value: impl Into<String>) -> Self { + Self(value.into()) + } +} |