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

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.