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