pub use super::conf::*;
use axum::extract::{Multipart, Path, Query};
use phf::{Map, OrderedMap};
pub use rumtk_core::strings::RUMString;
pub use rumtk_core::strings::{AsStr, RUMStringConversions, StringLike};
use rumtk_core::types::{RUMHashMap, RUMID};
use std::fmt::Display;
use std::ops::Deref;
use std::sync::Arc;
pub type RUMWebData = RUMHashMap<RUMString, RUMString>;
pub type URLPath<'a, 'b> = &'a [&'b str];
pub type AsyncURLPath = Arc<Vec<RUMString>>;
pub type URLParams<'a> = &'a RUMWebData;
pub type AsyncURLParams = Arc<RUMWebData>;
pub use crate::utils::response::*;
pub type RenderedPageComponents = Vec<RUMString>;
pub type RenderedPageComponentsResult = RUMResult<RenderedPageComponents>;
pub type RouterComponents = Path<Vec<RUMString>>;
pub type RouterParams = Query<RUMWebData>;
pub type RouterForm = Multipart;
pub type PageFunction = fn(SharedAppState) -> RenderedPageComponentsResult;
pub type PageMap = Map<&'static str, PageFunction>;
pub use crate::utils::form_data::{FormBuffer, FormData};
pub type RouterAPIPath = Path<RUMString>;
pub type APIPath = RUMString;
pub type APIFunction = fn(APIPath, RUMWebData, FormData, SharedAppState) -> HTMLResult;
pub type TextMap = RUMOrderedMap<RUMString, RUMString>;
pub type NestedTextMap = RUMOrderedMap<RUMString, TextMap>;
pub type NestedNestedTextMap = RUMOrderedMap<RUMString, NestedTextMap>;
pub type RootNestedNestedTextMap = RUMOrderedMap<RUMString, NestedNestedTextMap>;
pub type ConstTextMap = OrderedMap<&'static str, &'static str>;
pub type ConstNestedTextMap = OrderedMap<&'static str, &'static ConstTextMap>;
pub type ConstNestedNestedTextMap = OrderedMap<&'static str, &'static ConstNestedTextMap>;
pub type PipelineGroup = RUMHashMap<RUMString, RUMCommandLine>;
pub use askama::{Template as RUMWebTemplate, filters::HtmlSafe as RUMWebTemplateSafe};
use rumtk_core::base::RUMResult;
use rumtk_core::pipelines::pipeline_types::RUMCommandLine;
use rumtk_core::serde::RUMOrderedMap;
#[derive(Debug, Clone)]
pub struct RUMWebDataProxy(RUMWebData);
impl RUMWebDataProxy {
#[inline]
pub fn get_inner(&self) -> &RUMWebData {
&self.0
}
#[inline]
pub fn consume(mut self) -> RUMWebData {
self.0
}
pub fn from_params<K, V, const N: usize>(data: &[(K, V); N]) -> Self
where
K: Display + Sized,
V: Display + Sized,
{
let mut new_params = RUMWebData::with_capacity(data.len());
for (k, v) in data.iter() {
new_params.insert(
RUMString::from(k.to_string()),
RUMString::from(v.to_string()),
);
}
RUMWebDataProxy(new_params)
}
}
impl Deref for RUMWebDataProxy {
type Target = RUMWebData;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<&RUMWebData> for RUMWebDataProxy {
fn from(data: &RUMWebData) -> Self {
RUMWebDataProxy(data.clone())
}
}
impl<const N: usize> From<&&[(&str, &str); N]> for RUMWebDataProxy {
fn from(data: &&[(&str, &str); N]) -> Self {
Self::from_params(data)
}
}
impl<const N: usize> From<&[(&str, &str); N]> for RUMWebDataProxy {
fn from(data: &[(&str, &str); N]) -> Self {
Self::from_params(data)
}
}
impl<const N: usize> From<&[(&str, &RUMString); N]> for RUMWebDataProxy {
fn from(data: &[(&str, &RUMString); N]) -> Self {
Self::from_params(data)
}
}
impl<const N: usize> From<&[(&str, RUMString); N]> for RUMWebDataProxy {
fn from(data: &[(&str, RUMString); N]) -> Self {
Self::from_params(data)
}
}
impl<const N: usize> From<&[(&str, RUMID); N]> for RUMWebDataProxy {
fn from(data: &[(&str, RUMID); N]) -> Self {
Self::from_params(data)
}
}