diff --git a/specta/src/datatype/named.rs b/specta/src/datatype/named.rs index 18b0604..623f55d 100644 --- a/specta/src/datatype/named.rs +++ b/specta/src/datatype/named.rs @@ -1,4 +1,4 @@ -use std::{borrow::Cow, panic::Location}; +use std::{borrow::Cow, collections::HashSet, panic::Location}; use crate::{ DataType, TypeCollection, @@ -15,6 +15,7 @@ pub struct NamedDataType { pub(crate) module_path: Cow<'static, str>, pub(crate) location: Location<'static>, pub(crate) generics: Vec, + pub(crate) tags: HashSet, pub(crate) inner: DataType, } @@ -170,6 +171,21 @@ impl NamedDataType { pub fn set_ty(&mut self, ty: DataType) { self.inner = ty; } + + /// Get the tags associated with this type + pub fn tags(&self) -> &HashSet { + &self.tags + } + + /// Get a mutable reference to the tags associated with this type + pub fn tags_mut(&mut self) -> &mut HashSet { + &mut self.tags + } + + /// Set the tags associated with this type + pub fn set_tags(&mut self, tags: HashSet) { + self.tags = tags; + } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -187,3 +203,10 @@ pub enum DeprecatedType { note: Cow<'static, str>, }, } + +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +#[non_exhaustive] +pub enum TypeTag { + Date, + Custom(Cow<'static, str>), +}