Add ID type for filters

This commit is contained in:
D. Scott Boggs 2023-01-09 07:53:25 -05:00 committed by Scott Boggs
parent 9f4327f546
commit c5f199b460
1 changed files with 12 additions and 1 deletions

View File

@ -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<Status>,
}
/// Wrapper type for a filter ID string
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(transparent)]
pub struct FilterId(String);
impl AsRef<str> 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")]