rumtk_web/utils/
mod.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 mod app;
24pub mod conf;
25pub mod defaults;
26mod form_data;
27pub mod jobs;
28pub mod matcher;
29pub mod packaging;
30pub mod render;
31pub mod response;
32pub mod types;
33
34pub use render::*;
35pub use types::*;
36
37#[macro_export]
38macro_rules! rumtk_web_get_text_item {
39    ( $store:expr, $item:expr, $default:expr) => {{
40        match $store.get($item) {
41            Some(x) => x,
42            None => $default,
43        }
44    }};
45}
46
47#[macro_export]
48macro_rules! rumtk_web_get_param_eq {
49    ( $params:expr, $indx:expr, $comparison:expr, $default:expr ) => {{
50        match $params.get($indx) {
51            Some(x) => *x == $comparison,
52            None => $default,
53        }
54    }};
55}
56
57#[macro_export]
58macro_rules! rumtk_web_get_param {
59    ( $params:expr, $indx:expr, $default:expr ) => {{
60        match $params.get($indx) {
61            Some(x) => x.parse().unwrap_or($default),
62            None => $default,
63        }
64    }};
65}
66
67#[macro_export]
68macro_rules! rumtk_web_params_map {
69    ( $params:expr ) => {{
70        use $crate::types::RUMWebData;
71        let mut params = RUMWebData::with_capacity($params.len());
72
73        for (k, v) in $params.iter() {
74            params.insert(
75                RUMString::from(k.to_string()),
76                RUMString::from(v.to_string()),
77            );
78        }
79        params
80    }};
81}