1pub use super::conf::*;
22use axum::extract::{Multipart, Path, Query};
23use phf::Map;
24pub use rumtk_core::strings::RUMString;
25pub use rumtk_core::strings::{AsStr, CompactStringExt, RUMStringConversions, StringLike};
26use rumtk_core::types::{RUMHashMap, RUMID};
27use std::fmt::{Debug, Display};
28use std::sync::Arc;
29
30pub type RUMWebData = RUMHashMap<RUMString, RUMString>;
31pub type URLPath<'a, 'b> = &'a [&'b str];
32pub type AsyncURLPath = Arc<Vec<RUMString>>;
33pub type URLParams<'a> = &'a RUMWebData;
34pub type AsyncURLParams = Arc<RUMWebData>;
35
36pub use crate::utils::response::*;
38
39pub type RenderedPageComponents = Vec<RUMString>;
40pub type RenderedPageComponentsResult = RUMResult<RenderedPageComponents>;
41pub type RouterComponents = Path<Vec<RUMString>>;
43pub type RouterParams = Query<RUMWebData>;
44pub type RouterForm = Multipart;
45
46pub type ComponentFunction = fn(URLPath, URLParams, SharedAppState) -> HTMLResult;
48pub type PageFunction = fn(SharedAppState) -> RenderedPageComponentsResult;
49pub type ComponentMap = Map<&'static str, ComponentFunction>;
50pub type PageMap = Map<&'static str, PageFunction>;
51
52pub use crate::utils::form_data::{FormBuffer, FormData};
54pub type RouterAPIPath = Path<RUMString>;
55pub type APIPath = RUMString;
56pub type APIFunction = fn(APIPath, RUMWebData, FormData, SharedAppState) -> HTMLResult;
57
58pub use askama::Template as RUMWebTemplate;
59use rumtk_core::core::RUMResult;
60
61
62pub struct RUMWebDataProxy(RUMWebData);
72
73impl RUMWebDataProxy {
74 pub fn get_inner(&self) -> &RUMWebData {
75 &self.0
76 }
77
78 pub fn from_params<K, V, const N: usize>(data: &[(K, V); N]) -> Self
79 where
80 K: Display + Sized,
81 V: Display + Sized,
82 {
83 let mut new_params = RUMWebData::with_capacity(data.len());
84
85 for (k, v) in data.iter() {
86 new_params.insert(
87 RUMString::from(k.to_string()),
88 RUMString::from(v.to_string()),
89 );
90 }
91 RUMWebDataProxy(new_params)
92 }
93}
94
95impl From<&RUMWebData> for RUMWebDataProxy {
96 fn from(data: &RUMWebData) -> Self {
97 RUMWebDataProxy(data.clone())
98 }
99}
100
101impl<const N: usize> From<&&[(&str, &str); N]> for RUMWebDataProxy {
102 fn from(data: &&[(&str, &str); N]) -> Self {
103 Self::from_params(data)
104 }
105}
106
107impl<const N: usize> From<&[(&str, &str); N]> for RUMWebDataProxy {
108 fn from(data: &[(&str, &str); N]) -> Self {
109 Self::from_params(data)
110 }
111}
112
113impl<const N: usize> From<&[(&str, &RUMString); N]> for RUMWebDataProxy {
114 fn from(data: &[(&str, &RUMString); N]) -> Self {
115 Self::from_params(data)
116 }
117}
118
119impl<const N: usize> From<&[(&str, RUMID); N]> for RUMWebDataProxy {
120 fn from(data: &[(&str, RUMID); N]) -> Self {
121 Self::from_params(data)
122 }
123}