pub fn table_gen(path: &PathBuf, table_name: &str, rows: &RowsMetadata) -> Result<()> {
    let template = mustache::compile_str(TABLE_RS)?;
    let mut fields: Vec<Field> = Vec::new();

    for col_info in rows.values() {
        let mut field: Field = Default::default();

        for col in col_info {
            match &(*col.column_name())[..] {
                "COLUMN_NAME" => {
                    field.set_field_name(to_snake_case(&data_as_str(col)?));
                }
                "DATA_TYPE" => {
                    field.set_field_type(map_data_type(&data_as_str(col)?)?);
                }
                "NULLABLE" => map_nullable(&data_as_str(col)?, &mut field)?,
                _ => {}
            }
        }
        fields.push(field);
    }
    let mut derives = Vec::new();
    let derive_names = vec!["Clone", "Default", "Debug", "PartialEq"];
    for (idx, derive) in derive_names.iter().enumerate() {
        let derive: Derive = DeriveBuilder::default()
            .name(derive.to_string())
            .comma(idx < (derive_names.len() - 1))
            .build()?;
        derives.push(derive);
    }

    let table: Table = TableBuilder::default()
        .struct_name(to_pascal_case(table_name))
        .derives(derives)
        .field(fields)
        .build()?;

    let lc_table_name: String = table_name.chars().map(|c| c.to_lowercase().to_string()).collect();
    let mut module_path = PathBuf::from(path);
    module_path.push(lc_table_name);
    module_path.set_extension("rs");

    let table_file = File::create(module_path)?;
    let mut writer = BufWriter::new(table_file);
    template.render(&mut writer, &table)?;
    Ok(())
}
/// Generate Rust code for the given `RowsMetadata`.
Generate Rust code for the given `RowsMetadata`.
Generate Rust code for the given ` RowsMetadata ` .
pub fn table_gen(path: &PathBuf, table_name: &str, rows: &RowsMetadata) -> Result<()> {
    let template = mustache::compile_str(TABLE_RS)?;
    let mut fields: Vec<Field> = Vec::new();
    for col_info in rows.values() {
        let mut field: Field = Default::default();
        for col in col_info {
            match &(*col.column_name())[..] {
                "COLUMN_NAME" => {
                    field.set_field_name(to_snake_case(&data_as_str(col)?));
                }
                "DATA_TYPE" => {
                    field.set_field_type(map_data_type(&data_as_str(col)?)?);
                }
                "NULLABLE" => map_nullable(&data_as_str(col)?, &mut field)?,
                _ => {}
            }
        }
        fields.push(field);
    }
    let mut derives = Vec::new();
    let derive_names = vec!["Clone", "Default", "Debug", "PartialEq"];
    for (idx, derive) in derive_names.iter().enumerate() {
        let derive: Derive = DeriveBuilder::default()
            .name(derive.to_string())
            .comma(idx < (derive_names.len() - 1))
            .build()?;
        derives.push(derive);
    }
    let table: Table = TableBuilder::default()
        .struct_name(to_pascal_case(table_name))
        .derives(derives)
        .field(fields)
        .build()?;
    let lc_table_name: String = table_name.chars().map(|c| c.to_lowercase().to_string()).collect();
    let mut module_path = PathBuf::from(path);
    module_path.push(lc_table_name);
    module_path.set_extension("rs");
    let table_file = File::create(module_path)?;
    let mut writer = BufWriter::new(table_file);
    template.render(&mut writer, &table)?;
    Ok(())
}
pub fn table_gen ( path : & PathBuf , table_name : & str , rows : & RowsMetadata ) -> Result < ( ) > { let template = mustache :: compile_str ( TABLE_RS ) ? ; let mut fields : Vec < Field > = Vec :: new ( ) ; for col_info in rows . values ( ) { let mut field : Field = Default :: default ( ) ; for col in col_info { match & ( * col . column_name ( ) ) [ .. ] { " " => { field . set_field_name ( to_snake_case ( & data_as_str ( col ) ? ) ) ; } " " => { field . set_field_type ( map_data_type ( & data_as_str ( col ) ? ) ? ) ; } " " => map_nullable ( & data_as_str ( col ) ? , & mut field ) ? , _ => { } } } fields . push ( field ) ; } let mut derives = Vec :: new ( ) ; let derive_names = vec ! [ " " " " " " " " ] ; for ( idx , derive ) in derive_names . iter ( ) . enumerate ( ) { let derive : Derive = DeriveBuilder :: default ( ) . name ( derive . to_string ( ) ) . comma ( idx < ( derive_names . len ( ) - 1 ) ) . build ( ) ? ; derives . push ( derive ) ; } let table : Table = TableBuilder :: default ( ) . struct_name ( to_pascal_case ( table_name ) ) . derives ( derives ) . field ( fields ) . build ( ) ? ; let lc_table_name : String = table_name . chars ( ) . map ( | c | c . to_lowercase ( ) . to_string ( ) ) . collect ( ) ; let mut module_path = PathBuf :: from ( path ) ; module_path . push ( lc_table_name ) ; module_path . set_extension ( " " ) ; let table_file = File :: create ( module_path ) ? ; let mut writer = BufWriter :: new ( table_file ) ; template . render ( & mut writer , & table ) ? ; Ok ( ( ) ) }
Generate Rust code for the given `RowsMetadata`.
Generate Rust code for the given ` RowsMetadata ` .
path
&PathBuf
table_name
&str
rows
&RowsMetadata