rumtk_web/utils/types.rs
1/*
2 * rumtk attempts to implement HL7 and medical protocols for interoperability in medicine.
3 * This toolkit aims to be reliable, simple, performant, and standards compliant.
4 * Copyright (C) 2025 Luis M. Santos, M.D.
5 * Copyright (C) 2025 MedicalMasses L.L.C.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21pub use super::conf::*;
22use axum::extract::{Path, Query};
23use axum::response::Html;
24use phf::Map;
25use std::collections::HashMap;
26use std::sync::Arc;
27
28pub use rumtk_core::strings::RUMString;
29pub use rumtk_core::strings::{CompactStringExt, RUMStringConversions, UTFStringExtensions};
30
31pub type URLPath<'a, 'b> = &'a [&'b str];
32pub type AsyncURLPath = Arc<Vec<RUMString>>;
33pub type URLParams<'a> = &'a HashMap<RUMString, RUMString>;
34pub type AsyncURLParams = Arc<HashMap<RUMString, RUMString>>;
35pub type HTMLResult = Result<Html<String>, RUMString>;
36pub type RenderedPageComponents = Vec<RUMString>;
37/* Router Match Types */
38pub type RouterComponents = Path<Vec<RUMString>>;
39pub type RouterParams = Query<HashMap<RUMString, RUMString>>;
40
41/* Config Types */
42pub type ComponentFunction = fn(URLPath, URLParams, SharedAppConf) -> HTMLResult;
43pub type PageFunction = fn(SharedAppConf) -> RenderedPageComponents;
44pub type ComponentMap = Map<&'static str, ComponentFunction>;
45pub type PageMap = Map<&'static str, PageFunction>;