Struct test_data_generation::configs::Configs [−][src]
pub struct Configs { /* fields omitted */ }
Implementations
Constructs a new Configs
Arguments
- `path: &String - The full path name (including the file name and extension) to the configuration file.
#Example
extern crate test_data_generation;
use test_data_generation::configs::Configs;
fn main() {
// initalize a new Configs
let mut cfg = Configs::new(&String::from("./tests/config/tdg.yaml"));
cfg.load_config_file();
// verify the configuration file has been loaded
println!("{:?}", cfg);
}
Constructs a new Configs object from a serialized (JSON) string. This is used when restoring from “archive”
#Example
extern crate test_data_generation;
use test_data_generation::configs::Configs;
fn main() {
let serialized = "{\"file\":\"./tests/config/tdg.yaml\"}";
let mut cfg = Configs::from_serialized(&serialized);
assert_eq!(cfg.get_config_file_path(), "./tests/config/tdg.yaml");
}
Loads the configuration file using the path that was provided during calling a new Configs object
#Example
extern crate test_data_generation;
use test_data_generation::configs::Configs;
fn main() {
// initalize a new Configs
let mut cfg = Configs::new(&String::from("./tests/config/tdg.yaml"));
// verify the configuration file path was set
println!("The configuration fiel is located at {}", cfg.get_config_file_path());
}
Loads the configuration file using the path that was provided during calling a new Configs object
#Example
extern crate test_data_generation;
use test_data_generation::configs::Configs;
fn main() {
// initalize a new Configs
let mut cfg = Configs::new(&String::from("./tests/config/tdg.yaml"));
cfg.load_config_file();
// verify the configuration file has been loaded
println!("{:?}", cfg);
}
This function converts the Configs object to a serialize JSON string.
#Example
extern crate test_data_generation;
use test_data_generation::configs::Configs;
fn main() {
//create a Configs object from a configuration file
let mut cfg = Configs::new(&String::from("./tests/config/tdg.yaml"));
cfg.load_config_file();
println!("{}", cfg.serialize());
// {"key":"r","prior_key":null,"next_key":null,"pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":2}
}
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more