Skip to main content

rumtk_web_load_conf

Macro rumtk_web_load_conf 

Source
macro_rules! rumtk_web_load_conf {
    ( $args:expr ) => { ... };
    ( $args:expr, $path:expr ) => { ... };
}
Expand description

Load the configuration for this app at the specified path. By default, we look into ./app.json as the location of the configuration.

ยงExample

use std::fs;
use rumtk_core::rumtk_new_lock;
use rumtk_web::{rumtk_web_save_conf, rumtk_web_load_conf, rumtk_web_get_config};
use rumtk_web::{AppConf};
use rumtk_core::strings::RUMString;

#[derive(Default)]
struct Args {
    title: RUMString,
    description: RUMString,
    company: RUMString,
    copyright: RUMString,
    css_source_dir: RUMString,
    ip: RUMString,
    upload_limit: usize,
    threads: usize,
    skip_default_css: bool,
}

let path = "./test_conf.json";

rumtk_web_save_conf!(&path);
let app_state = rumtk_web_load_conf!(Args::default());
let config = rumtk_web_get_config!(app_state).clone();

if fs::exists(&path).unwrap() {
    fs::remove_file(&path).unwrap();
}

assert_eq!(config, AppConf::default(), "Configuration was not loaded properly!");