pub fn from_map(gen_type: &String, map: &serde_json::Map<String, Value>) -> Option<Generator> {
    match gen_type.as_str() {
      "RandomInt" => {
        let min = <i32>::json_to_number(map, "min", 0);
        let max = <i32>::json_to_number(map, "max", 10);
        Some(Generator::RandomInt(min, max))
      },
      "Uuid" => Some(Generator::Uuid),
      "RandomDecimal" => Some(Generator::RandomDecimal(<u16>::json_to_number(map, "digits", 10))),
      "RandomHexadecimal" => Some(Generator::RandomHexadecimal(<u16>::json_to_number(map, "digits", 10))),
      "RandomString" => Some(Generator::RandomString(<u16>::json_to_number(map, "size", 10))),
      "Regex" => map.get("regex").map(|val| Generator::Regex(json_to_string(val))),
      "Date" => Some(Generator::Date(map.get("format").map(|f| json_to_string(f)))),
      "Time" => Some(Generator::Time(map.get("format").map(|f| json_to_string(f)))),
      "DateTime" => Some(Generator::DateTime(map.get("format").map(|f| json_to_string(f)))),
      "RandomBoolean" => Some(Generator::RandomBoolean),
      "ProviderState" => Some(Generator::ProviderStateGenerator(map.get("expression").map(|f| json_to_string(f)).unwrap())),
      _ => {
        warn!("'{}' is not a valid generator type", gen_type);
        None
      }
    }
  }
/// Converts a JSON map into a `Generator` struct, returning `None` if it can not be converted.
Converts a JSON map into a `Generator` struct, returning `None` if it can not be converted.
Converts a JSON map into a ` Generator ` struct returning ` None ` if it can not be converted .
pub fn from_map(gen_type: &String, map: &serde_json::Map<String, Value>) -> Option<Generator> {
    match gen_type.as_str() {
      "RandomInt" => {
        let min = <i32>::json_to_number(map, "min", 0);
        let max = <i32>::json_to_number(map, "max", 10);
        Some(Generator::RandomInt(min, max))
      },
      "Uuid" => Some(Generator::Uuid),
      "RandomDecimal" => Some(Generator::RandomDecimal(<u16>::json_to_number(map, "digits", 10))),
      "RandomHexadecimal" => Some(Generator::RandomHexadecimal(<u16>::json_to_number(map, "digits", 10))),
      "RandomString" => Some(Generator::RandomString(<u16>::json_to_number(map, "size", 10))),
      "Regex" => map.get("regex").map(|val| Generator::Regex(json_to_string(val))),
      "Date" => Some(Generator::Date(map.get("format").map(|f| json_to_string(f)))),
      "Time" => Some(Generator::Time(map.get("format").map(|f| json_to_string(f)))),
      "DateTime" => Some(Generator::DateTime(map.get("format").map(|f| json_to_string(f)))),
      "RandomBoolean" => Some(Generator::RandomBoolean),
      "ProviderState" => Some(Generator::ProviderStateGenerator(map.get("expression").map(|f| json_to_string(f)).unwrap())),
      _ => {
        warn!("'{}' is not a valid generator type", gen_type);
        None
      }
    }
  }
pub fn from_map ( gen_type : & String , map : & serde_json :: Map < String , Value > ) -> Option < Generator > { match gen_type . as_str ( ) { " " => { let min = < i32 > :: json_to_number ( map , " " , 0 ) ; let max = < i32 > :: json_to_number ( map , " " , 10 ) ; Some ( Generator :: RandomInt ( min , max ) ) } , " " => Some ( Generator :: Uuid ) , " " => Some ( Generator :: RandomDecimal ( < u16 > :: json_to_number ( map , " " , 10 ) ) ) , " " => Some ( Generator :: RandomHexadecimal ( < u16 > :: json_to_number ( map , " " , 10 ) ) ) , " " => Some ( Generator :: RandomString ( < u16 > :: json_to_number ( map , " " , 10 ) ) ) , " " => map . get ( " " ) . map ( | val | Generator :: Regex ( json_to_string ( val ) ) ) , " " => Some ( Generator :: Date ( map . get ( " " ) . map ( | f | json_to_string ( f ) ) ) ) , " " => Some ( Generator :: Time ( map . get ( " " ) . map ( | f | json_to_string ( f ) ) ) ) , " " => Some ( Generator :: DateTime ( map . get ( " " ) . map ( | f | json_to_string ( f ) ) ) ) , " " => Some ( Generator :: RandomBoolean ) , " " => Some ( Generator :: ProviderStateGenerator ( map . get ( " " ) . map ( | f | json_to_string ( f ) ) . unwrap ( ) ) ) , _ => { warn ! ( " " gen_type ) ; None } } }
Converts a JSON map into a `Generator` struct, returning `None` if it can not be converted.
Converts a JSON map into a ` Generator ` struct returning ` None ` if it can not be converted .
gen_type
&String
map
&serde_json::Map<String, Value>
gen_type
&String
map
&serde_json::Map<String, Value>