aboutsummaryrefslogtreecommitdiff
path: root/common/src
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2026-01-06 19:10:37 +0100
committermetamuffin <metamuffin@disroot.org>2026-01-06 19:10:37 +0100
commitffa6b5c4ae2cdd3e07426ed0330f3f66e90ee57b (patch)
tree79a03bc7ed938a3698ece0878f0ce5337ff6db23 /common/src
parentffbdb9ce397a6408d5a91cbdcbaf4e13b0c3ba0b (diff)
downloadjellything-ffa6b5c4ae2cdd3e07426ed0330f3f66e90ee57b.tar
jellything-ffa6b5c4ae2cdd3e07426ed0330f3f66e90ee57b.tar.bz2
jellything-ffa6b5c4ae2cdd3e07426ed0330f3f66e90ee57b.tar.zst
tag registry
Diffstat (limited to 'common/src')
-rw-r--r--common/src/lib.rs27
-rw-r--r--common/src/routes.rs6
2 files changed, 22 insertions, 11 deletions
diff --git a/common/src/lib.rs b/common/src/lib.rs
index 9ab0b91..1359c73 100644
--- a/common/src/lib.rs
+++ b/common/src/lib.rs
@@ -4,26 +4,39 @@
Copyright (C) 2025 metamuffin <metamuffin.org>
*/
#![feature(array_try_map)]
-pub mod api;
pub mod routes;
-pub mod user;
-use jellyobject::{Object, Tag, TypedTag};
+use jellyobject::{Object, Registry, Tag, TagInfo, TypedTag};
pub use jellystream_types as stream;
-use std::marker::PhantomData;
+use std::{any::TypeId, marker::PhantomData, sync::LazyLock};
+
+pub use jellyobject;
+
+pub static TAGREG: LazyLock<Registry> = LazyLock::new(|| {
+ let mut reg = Registry::default();
+ register_fields(&mut reg);
+ register_enums(&mut reg);
+ reg
+});
macro_rules! fields {
($($id:ident: $type:ty = $tag:literal $name:literal;)*) => {
$(pub const $id: TypedTag<$type> = TypedTag(Tag($tag), PhantomData);)*
+ fn register_fields(reg: &mut Registry) {
+ $(reg.add(Tag($tag), TagInfo { name: $name, r#type: Some(TypeId::of::<$type>()) });)*
+ }
};
}
macro_rules! enums {
($($id:ident = $tag:literal $name:literal;)*) => {
$(pub const $id: Tag = Tag($tag);)*
+ fn register_enums(reg: &mut Registry) {
+ $(reg.add(Tag($tag), TagInfo { name: $name, r#type: None });)*
+ }
};
}
fields! {
- // Tag counter: 32
+ // Tag counter: 36
NO_KIND: Tag = 1 "kind";
NO_TITLE: &str = 2 "title";
@@ -44,8 +57,8 @@ fields! {
NO_CREDIT: Object = 33 "credit"; // multi
CR_NODE: u64 = 34 "node";
- CR_KIND: Tag = 34 "kind";
- CR_JOB: &str = 34 "node";
+ CR_KIND: Tag = 35 "kind";
+ CR_ROLE: &str = 36 "role"; // multi
TR_KIND: Tag = 16 "kind";
TR_SOURCE: &str = 17 "source";
diff --git a/common/src/routes.rs b/common/src/routes.rs
index b11a622..48f975a 100644
--- a/common/src/routes.rs
+++ b/common/src/routes.rs
@@ -3,8 +3,6 @@
which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
Copyright (C) 2026 metamuffin <metamuffin.org>
*/
-use crate::api::NodeFilterSort;
-
pub fn u_home() -> String {
"/home".to_owned()
}
@@ -23,7 +21,7 @@ pub fn u_node_slug_player_time(node: &str, time: f64) -> String {
pub fn u_node_image(node: &str, slot: &str, size: usize) -> String {
format!("/n/{node}/image/{slot}?size={size}")
}
-pub fn u_node_slug_watched(node: &str, state: ApiWatchedState) -> String {
+pub fn u_node_slug_watched(node: &str, state: &str) -> String {
format!("/n/{node}/watched?state={state}")
}
pub fn u_node_slug_person_asset(node: &str, group: &str, index: usize, size: usize) -> String {
@@ -41,7 +39,7 @@ pub fn u_node_slug_progress(node: &str, time: f64) -> String {
pub fn u_items() -> String {
"/items".to_string()
}
-pub fn u_items_filter(page: usize, _filter: &NodeFilterSort) -> String {
+pub fn u_items_filter(page: usize) -> String {
// TODO
format!("/items?page={page}")
}