[][src]Struct test_data_generation::configs::Configs

pub struct Configs { /* fields omitted */ }

Implementations

impl Configs[src]

pub fn new(path: &String) -> Configs[src]

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);
}

pub fn from_serialized(serialized: &str) -> Configs[src]

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");
}

pub fn get_config_file_path(&self) -> &str[src]

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());
}

pub fn load_config_file(&mut self)[src]

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);
}

pub fn serialize(&mut self) -> String[src]

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

impl Debug for Configs[src]

impl<'de> Deserialize<'de> for Configs[src]

impl Serialize for Configs[src]

Auto Trait Implementations

impl RefUnwindSafe for Configs

impl Send for Configs

impl Sync for Configs

impl Unpin for Configs

impl UnwindSafe for Configs

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DebugAny for T where
    T: Any + Debug

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> UnsafeAny for T where
    T: Any

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,