aboutsummaryrefslogtreecommitdiff
path: root/common/object/src/registry.rs
diff options
context:
space:
mode:
Diffstat (limited to 'common/object/src/registry.rs')
-rw-r--r--common/object/src/registry.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/common/object/src/registry.rs b/common/object/src/registry.rs
new file mode 100644
index 0000000..7148efd
--- /dev/null
+++ b/common/object/src/registry.rs
@@ -0,0 +1,27 @@
+/*
+ This file is part of jellything (https://codeberg.org/metamuffin/jellything)
+ which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
+ Copyright (C) 2026 metamuffin <metamuffin.org>
+*/
+
+use crate::Tag;
+use log::error;
+use std::{any::TypeId, collections::BTreeMap};
+
+#[derive(Default)]
+pub struct Registry {
+ tags: BTreeMap<Tag, TagInfo>,
+}
+impl Registry {
+ pub fn add(&mut self, tag: Tag, info: TagInfo) {
+ if let Some(other) = self.tags.get(&tag) {
+ error!("Tag conflict: {:?} vs {:?}", info.name, other.name)
+ }
+ self.tags.insert(tag, info);
+ }
+}
+
+pub struct TagInfo {
+ pub name: &'static str,
+ pub r#type: Option<TypeId>,
+}