Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion specta/src/datatype/named.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{borrow::Cow, panic::Location};
use std::{borrow::Cow, collections::HashSet, panic::Location};

use crate::{
DataType, TypeCollection,
Expand All @@ -15,6 +15,7 @@ pub struct NamedDataType {
pub(crate) module_path: Cow<'static, str>,
pub(crate) location: Location<'static>,
pub(crate) generics: Vec<Generic>,
pub(crate) tags: HashSet<TypeTag>,
pub(crate) inner: DataType,
}

Expand Down Expand Up @@ -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<TypeTag> {
&self.tags
}

/// Get a mutable reference to the tags associated with this type
pub fn tags_mut(&mut self) -> &mut HashSet<TypeTag> {
&mut self.tags
}

/// Set the tags associated with this type
pub fn set_tags(&mut self, tags: HashSet<TypeTag>) {
self.tags = tags;
}
}

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
Expand All @@ -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>),
}
Loading