1pub use super::conf::*;
22use axum::extract::{Multipart, Path, Query};
23use phf::{Map, OrderedMap};
24pub use rumtk_core::strings::RUMString;
25pub use rumtk_core::strings::{AsStr, RUMStringConversions, StringLike};
26use rumtk_core::types::{RUMHashMap, RUMID};
27use std::fmt::Display;
28use std::ops::Deref;
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
37pub use crate::utils::response::*;
39
40pub type RenderedPageComponents = Vec<RUMString>;
41pub type RenderedPageComponentsResult = RUMResult<RenderedPageComponents>;
42pub type RouterComponents = Path<Vec<RUMString>>;
44pub type RouterParams = Query<RUMWebData>;
45pub type RouterForm = Multipart;
46
47pub type PageFunction = fn(SharedAppState) -> RenderedPageComponentsResult;
49pub type PageMap = Map<&'static str, PageFunction>;
50
51pub use crate::utils::form_data::{FormBuffer, FormData};
53pub type RouterAPIPath = Path<RUMString>;
54pub type APIPath = RUMString;
55pub type APIFunction = fn(APIPath, RUMWebData, FormData, SharedAppState) -> HTMLResult;
56
57pub type TextMap = RUMOrderedMap<RUMString, RUMString>;
59pub type NestedTextMap = RUMOrderedMap<RUMString, TextMap>;
60pub type NestedNestedTextMap = RUMOrderedMap<RUMString, NestedTextMap>;
61pub type RootNestedNestedTextMap = RUMOrderedMap<RUMString, NestedNestedTextMap>;
62
63pub type ConstTextMap = OrderedMap<&'static str, &'static str>;
64pub type ConstNestedTextMap = OrderedMap<&'static str, &'static ConstTextMap>;
65pub type ConstNestedNestedTextMap = OrderedMap<&'static str, &'static ConstNestedTextMap>;
66
67pub type PipelineGroup = RUMHashMap<RUMString, RUMCommandLine>;
68
69pub use askama::{Template as RUMWebTemplate, filters::HtmlSafe as RUMWebTemplateSafe};
70
71use rumtk_core::base::RUMResult;
72use rumtk_core::pipelines::pipeline_types::RUMCommandLine;
73use rumtk_core::serde::RUMOrderedMap;
74
75#[derive(Debug, Clone)]
85pub struct RUMWebDataProxy(RUMWebData);
86
87impl RUMWebDataProxy {
88 #[inline]
89 pub fn get_inner(&self) -> &RUMWebData {
90 &self.0
91 }
92
93 #[inline]
94 pub fn consume(mut self) -> RUMWebData {
95 self.0
96 }
97
98 pub fn from_params<K, V, const N: usize>(data: &[(K, V); N]) -> Self
99 where
100 K: Display + Sized,
101 V: Display + Sized,
102 {
103 let mut new_params = RUMWebData::with_capacity(data.len());
104
105 for (k, v) in data.iter() {
106 new_params.insert(
107 RUMString::from(k.to_string()),
108 RUMString::from(v.to_string()),
109 );
110 }
111 RUMWebDataProxy(new_params)
112 }
113}
114
115impl Deref for RUMWebDataProxy {
116 type Target = RUMWebData;
117
118 fn deref(&self) -> &Self::Target {
119 &self.0
120 }
121}
122
123impl From<&RUMWebData> for RUMWebDataProxy {
124 fn from(data: &RUMWebData) -> Self {
125 RUMWebDataProxy(data.clone())
126 }
127}
128
129impl<const N: usize> From<&&[(&str, &str); N]> for RUMWebDataProxy {
130 fn from(data: &&[(&str, &str); N]) -> Self {
131 Self::from_params(data)
132 }
133}
134
135impl<const N: usize> From<&[(&str, &str); N]> for RUMWebDataProxy {
136 fn from(data: &[(&str, &str); N]) -> Self {
137 Self::from_params(data)
138 }
139}
140
141impl<const N: usize> From<&[(&str, &RUMString); N]> for RUMWebDataProxy {
142 fn from(data: &[(&str, &RUMString); N]) -> Self {
143 Self::from_params(data)
144 }
145}
146
147impl<const N: usize> From<&[(&str, RUMString); N]> for RUMWebDataProxy {
148 fn from(data: &[(&str, RUMString); N]) -> Self {
149 Self::from_params(data)
150 }
151}
152
153impl<const N: usize> From<&[(&str, RUMID); N]> for RUMWebDataProxy {
154 fn from(data: &[(&str, RUMID); N]) -> Self {
155 Self::from_params(data)
156 }
157}