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  Nick Stephenson
6 * Copyright (C) 2025  Ethan Dixon
7 * Copyright (C) 2025  MedicalMasses L.L.C.
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22 */
23pub use super::conf::*;
24use axum::extract::{Multipart, Path, Query};
25use phf::Map;
26pub use rumtk_core::strings::RUMString;
27pub use rumtk_core::strings::{CompactStringExt, RUMStringConversions, UTFStringExtensions};
28use rumtk_core::types::RUMHashMap;
29use std::sync::Arc;
30
31pub type RUMWebData = RUMHashMap<RUMString, RUMString>;
32pub type URLPath<'a, 'b> = &'a [&'b str];
33pub type AsyncURLPath = Arc<Vec<RUMString>>;
34pub type URLParams<'a> = &'a RUMWebData;
35pub type AsyncURLParams = Arc<RUMWebData>;
36
37/* Responses */
38pub use crate::utils::response::*;
39
40pub type RenderedPageComponents = Vec<RUMString>;
41/* Router Match Types */
42pub type RouterComponents = Path<Vec<RUMString>>;
43pub type RouterParams = Query<RUMWebData>;
44pub type RouterForm = Multipart;
45
46/* Config Types */
47pub type ComponentFunction = fn(URLPath, URLParams, SharedAppState) -> HTMLResult;
48pub type PageFunction = fn(SharedAppState) -> RenderedPageComponents;
49pub type ComponentMap = Map<&'static str, ComponentFunction>;
50pub type PageMap = Map<&'static str, PageFunction>;
51
52/* API Types */
53pub type RouterAPIPath = Path<RUMString>;
54pub type APIPath<'a> = &'a str;
55pub type APIFunction = fn(APIPath, URLParams, Multipart, SharedAppState) -> HTMLResult;