pub fn define_structs_from_file_contents(
    root: &Path,
    struct_name: &str,
    format: Option<Format>,
    options: &Options
) -> Result<TokenStream, Error>
Expand description

Define a set of Rust structs based on the contents of all files in the given directory.

Examples

let tokens = codegen::define_structs_from_file_contents(
    "./my_dir".as_ref(),
    "FileStruct",
    None,
    &Options::minimal(),
).unwrap();

// Assuming that the toml files in ./my_dir look like:
//
//  field_a = 1
//  field_b = 2

assert_eq!(tokens.to_string(), quote!(
    #[allow(non_camel_case_types)]
    pub enum FileStruct {
        pub field_a: i64,
        pub field_b: i64,
    }
).to_string());