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