diff options
Diffstat (limited to 'common')
| -rw-r--r-- | common/src/api.rs | 127 | ||||
| -rw-r--r-- | common/src/user.rs | 4 |
2 files changed, 22 insertions, 109 deletions
diff --git a/common/src/api.rs b/common/src/api.rs index 89cfe16..d9f27c5 100644 --- a/common/src/api.rs +++ b/common/src/api.rs @@ -4,116 +4,27 @@ Copyright (C) 2026 metamuffin <metamuffin.org> */ -use jellyobject::{Object, Tag, enums, fields}; +use jellyobject::{Object, Tag}; +use std::collections::BTreeMap; -fields! { - QUERY_PARENT: u64 = b"prnt"; - QUERY_SEARCH: &str = b"sear"; - QUERY_KIND: Tag = b"kind"; // multi - QUERY_SORT: Tag = b"sort"; // one of RTYP_*, NU_RATING, NO_DURATION, NO_NAME - QUERY_SORT_ASCENDING: () = b"sasc"; - - VIEW_TITLE: &str = b"titl"; - VIEW_MESSAGE: Object = b"mesg"; - VIEW_NODE_PAGE: Object = b"npag"; - VIEW_NODE_LIST: Object = b"nlis"; // multi - VIEW_PLAYER: Object = b"play"; - VIEW_STATGROUP: Object = b"stag"; - VIEW_STATTEXT: Object = b"stat"; - VIEW_ACCOUNT_LOGIN: () = b"acli"; - VIEW_ACCOUNT_LOGOUT: () = b"aclo"; - VIEW_ACCOUNT_SET_PASSWORD: Object = b"acsp"; - VIEW_ADMIN_DASHBOARD: () = b"adda"; - VIEW_ADMIN_IMPORT: Object = b"adim"; - VIEW_ADMIN_INFO: Object = b"adin"; - VIEW_ADMIN_LOG: Object = b"adlo"; - VIEW_ADMIN_USER_LIST: Object = b"adul"; - VIEW_ADMIN_USER: Object = b"adus"; - VIEW_USER_SETTINGS: Object = b"uset"; - - ADMIN_IMPORT_BUSY: () = b"busy"; - ADMIN_IMPORT_ERROR: &str = b"erro"; // multi - ADMIN_INFO_TITLE: &str = b"aiti"; - ADMIN_INFO_TEXT: &str = b"aite"; - ADMIN_LOG_MESSAGE: &str = b"aite"; - - SETPW_USERNAME: &str = b"spwu"; - SETPW_PASSWORD: &str = b"spwp"; - - ADMIN_USER_LIST_ITEM: Object = b"item"; - - NKU_NODE: Object = b"node"; - NKU_UDATA: Object = b"udat"; - NKU_ROLE: &str = b"role"; - - NODELIST_TITLE: &str = b"titl"; - NODELIST_DISPLAYSTYLE: Tag = b"dsty"; - NODELIST_ITEM: Object = b"item"; // multi - NODELIST_CONTINUATION: &str = b"cont"; - - MESSAGE_KIND: &str = b"kind"; - MESSAGE_TEXT: &str = b"text"; - - STATGROUP_TITLE: &str = b"titl"; - STATGROUP_BIN: Object = b"bin1"; - - STAT_NAME: &str = b"name"; - STAT_COUNT: u64 = b"cont"; - STAT_TOTAL_SIZE: u64 = b"tlsz"; - STAT_TOTAL_DURATION: f64 = b"tldu"; - STAT_MAX_SIZE: u64 = b"mxsz"; - STAT_MAX_DURATION: f64 = b"mxdu"; +#[derive(Debug, Clone, Copy)] +pub struct Nku<'a> { + pub node: Object<'a>, + pub userdata: Object<'a>, + pub role: Option<&'a str>, } -enums! { - NLSTYLE_GRID = b"grid"; - NLSTYLE_INLINE = b"inli"; - NLSTYLE_LIST = b"list"; - NLSTYLE_HIGHLIGHT = b"hglt"; +pub struct Stats { + pub all: StatsBin, + pub by_kind: BTreeMap<Tag, StatsBin>, } -// use crate::user::{NodeUserData, User}; -// use std::{collections::BTreeMap, sync::Arc, time::Duration}; -// pub struct ApiNodeResponse { -// pub parents: NodesWithUdata, -// pub children: NodesWithUdata, -// pub node: Arc<Node>, -// pub userdata: NodeUserData, -// } - -// pub struct ApiSearchResponse { -// pub count: usize, -// pub results: NodesWithUdata, -// pub duration: Duration, -// } - -// pub struct ApiItemsResponse { -// pub count: usize, -// pub pages: usize, -// pub items: NodesWithUdata, -// } - -// pub struct ApiHomeResponse { -// pub toplevel: NodesWithUdata, -// pub categories: Vec<(String, NodesWithUdata)>, -// } - -// pub struct ApiStatsResponse { -// pub kinds: BTreeMap<NodeKind, StatsBin>, -// pub total: StatsBin, -// } - -// pub struct ApiAdminUsersResponse { -// pub users: Vec<User>, -// } - -// #[derive(Default, Serialize, Deserialize)] -// pub struct StatsBin { -// pub runtime: f64, -// pub size: u64, -// pub count: usize, -// pub max_runtime: f64, -// pub max_runtime_node: String, -// pub max_size: u64, -// pub max_size_node: String, -// } +pub struct StatsBin { + pub count: usize, + pub sum_duration: f64, + pub max_duration: f64, + pub max_duration_node: String, + pub sum_size: u64, + pub max_size: u64, + pub max_size_node: String, +} diff --git a/common/src/user.rs b/common/src/user.rs index 636046f..6511b10 100644 --- a/common/src/user.rs +++ b/common/src/user.rs @@ -4,7 +4,9 @@ Copyright (C) 2026 metamuffin <metamuffin.org> */ -use jellyobject::{Tag, enums, fields}; +use jellyobject::{Object, Tag, enums, fields}; + +pub type User<'a> = Object<'a>; fields! { USER_LOGIN: &str = b"Ulgn"; |