unsafe fn save_factions_data(&self, data: &[HashMap<String, String>]) -> Result<PackedFile> {
        let table_name = GAME_SELECTED.read().unwrap().get_tool_var("faction_painter_factions_table_name").ok_or_else(|| Error::from(ErrorKind::ToolVarNotFoundForGame("faction_painter_factions_table_name".to_owned())))?;
        let table_definition_name = GAME_SELECTED.read().unwrap().get_tool_var("faction_painter_factions_table_definition").ok_or_else(|| Error::from(ErrorKind::ToolVarNotFoundForGame("faction_painter_factions_table_definition".to_owned())))?;
        let row_key = GAME_SELECTED.read().unwrap().get_tool_var("faction_painter_factions_row_key").ok_or_else(|| Error::from(ErrorKind::ToolVarNotFoundForGame("faction_painter_factions_row_key".to_owned())))?;

        let banner_primary_colour_column_name = GAME_SELECTED.read().unwrap().get_tool_var("faction_painter_banner_primary_colour_column_name").ok_or_else(|| Error::from(ErrorKind::ToolVarNotFoundForGame("faction_painter_banner_primary_colour_column_name".to_owned())))?;
        let banner_secondary_colour_column_name = GAME_SELECTED.read().unwrap().get_tool_var("faction_painter_banner_secondary_colour_column_name").ok_or_else(|| Error::from(ErrorKind::ToolVarNotFoundForGame("faction_painter_banner_secondary_colour_column_name".to_owned())))?;
        let banner_tertiary_colour_column_name = GAME_SELECTED.read().unwrap().get_tool_var("faction_painter_banner_tertiary_colour_column_name").ok_or_else(|| Error::from(ErrorKind::ToolVarNotFoundForGame("faction_painter_banner_tertiary_colour_column_name".to_owned())))?;

        let uniform_primary_colour_column_name = GAME_SELECTED.read().unwrap().get_tool_var("faction_painter_uniform_primary_colour_column_name").ok_or_else(|| Error::from(ErrorKind::ToolVarNotFoundForGame("faction_painter_uniform_primary_colour_column_name".to_owned())))?;
        let uniform_secondary_colour_column_name = GAME_SELECTED.read().unwrap().get_tool_var("faction_painter_uniform_secondary_colour_column_name").ok_or_else(|| Error::from(ErrorKind::ToolVarNotFoundForGame("faction_painter_uniform_secondary_colour_column_name".to_owned())))?;
        let uniform_tertiary_colour_column_name = GAME_SELECTED.read().unwrap().get_tool_var("faction_painter_uniform_tertiary_colour_column_name").ok_or_else(|| Error::from(ErrorKind::ToolVarNotFoundForGame("faction_painter_uniform_tertiary_colour_column_name".to_owned())))?;

        if let Some(first) = data.iter().next() {
            if let Some(definition) = first.get(table_definition_name) {
                let mut table = DB::new(&table_name, None, &serde_json::from_str(definition)?);

                let banner_primary_colour_column = table.get_column_position_by_name(banner_primary_colour_column_name)?;
                let banner_secondary_colour_column = table.get_column_position_by_name(banner_secondary_colour_column_name)?;
                let banner_tertiary_colour_column = table.get_column_position_by_name(banner_tertiary_colour_column_name)?;

                let uniform_primary_colour_column = table.get_column_position_by_name(uniform_primary_colour_column_name)?;
                let uniform_secondary_colour_column = table.get_column_position_by_name(uniform_secondary_colour_column_name)?;
                let uniform_tertiary_colour_column = table.get_column_position_by_name(uniform_tertiary_colour_column_name)?;

                let table_data = data.par_iter()
                    .filter_map(|row_data| {
                        let row = row_data.get(row_key)?;
                        let mut row: Vec<DecodedData> = serde_json::from_str(row).ok()?;
                        let mut save_row = false;
                        if row_data.get("banner_primary").is_some() {
                            let banner_primary = u32::from_str_radix(row_data.get("banner_primary")?, 16).ok()?;
                            let banner_secondary = u32::from_str_radix(row_data.get("banner_secondary")?, 16).ok()?;
                            let banner_tertiary = u32::from_str_radix(row_data.get("banner_tertiary")?, 16).ok()?;

                            row[banner_primary_colour_column] = DecodedData::ColourRGB(banner_primary);
                            row[banner_secondary_colour_column] = DecodedData::ColourRGB(banner_secondary);
                            row[banner_tertiary_colour_column] = DecodedData::ColourRGB(banner_tertiary);

                            save_row = true;
                        }
                        if row_data.get("uniform_primary").is_some() {
                            let uniform_primary = u32::from_str_radix(row_data.get("uniform_primary")?, 16).ok()?;
                            let uniform_secondary = u32::from_str_radix(row_data.get("uniform_secondary")?, 16).ok()?;
                            let uniform_tertiary = u32::from_str_radix(row_data.get("uniform_tertiary")?, 16).ok()?;

                            row[uniform_primary_colour_column] = DecodedData::ColourRGB(uniform_primary);
                            row[uniform_secondary_colour_column] = DecodedData::ColourRGB(uniform_secondary);
                            row[uniform_tertiary_colour_column] = DecodedData::ColourRGB(uniform_tertiary);

                            save_row = true;
                        }

                        if save_row {
                            Some(row)
                        } else {
                            None
                        }
                    }).collect::<Vec<Vec<DecodedData>>>();

                table.set_table_data(&table_data)?;
                let path = vec!["db".to_owned(), table_name.to_owned(), self.get_file_name()];
                Ok(PackedFile::new_from_decoded(&DecodedPackedFile::DB(table), &path))
            } else { Err(ErrorKind::Impossibru.into()) }
        } else { Err(ErrorKind::Impossibru.into()) }
    }
/// This function takes care of saving the factions's data into a PackedFile.
This function takes care of saving the factions's data into a PackedFile.
This function takes care of saving the factions ' s data into a PackedFile .
unsafe fn save_factions_data(&self, data: &[HashMap<String, String>]) -> Result<PackedFile> {
        let table_name = GAME_SELECTED.read().unwrap().get_tool_var("faction_painter_factions_table_name").ok_or_else(|| Error::from(ErrorKind::ToolVarNotFoundForGame("faction_painter_factions_table_name".to_owned())))?;
        let table_definition_name = GAME_SELECTED.read().unwrap().get_tool_var("faction_painter_factions_table_definition").ok_or_else(|| Error::from(ErrorKind::ToolVarNotFoundForGame("faction_painter_factions_table_definition".to_owned())))?;
        let row_key = GAME_SELECTED.read().unwrap().get_tool_var("faction_painter_factions_row_key").ok_or_else(|| Error::from(ErrorKind::ToolVarNotFoundForGame("faction_painter_factions_row_key".to_owned())))?;
        let banner_primary_colour_column_name = GAME_SELECTED.read().unwrap().get_tool_var("faction_painter_banner_primary_colour_column_name").ok_or_else(|| Error::from(ErrorKind::ToolVarNotFoundForGame("faction_painter_banner_primary_colour_column_name".to_owned())))?;
        let banner_secondary_colour_column_name = GAME_SELECTED.read().unwrap().get_tool_var("faction_painter_banner_secondary_colour_column_name").ok_or_else(|| Error::from(ErrorKind::ToolVarNotFoundForGame("faction_painter_banner_secondary_colour_column_name".to_owned())))?;
        let banner_tertiary_colour_column_name = GAME_SELECTED.read().unwrap().get_tool_var("faction_painter_banner_tertiary_colour_column_name").ok_or_else(|| Error::from(ErrorKind::ToolVarNotFoundForGame("faction_painter_banner_tertiary_colour_column_name".to_owned())))?;
        let uniform_primary_colour_column_name = GAME_SELECTED.read().unwrap().get_tool_var("faction_painter_uniform_primary_colour_column_name").ok_or_else(|| Error::from(ErrorKind::ToolVarNotFoundForGame("faction_painter_uniform_primary_colour_column_name".to_owned())))?;
        let uniform_secondary_colour_column_name = GAME_SELECTED.read().unwrap().get_tool_var("faction_painter_uniform_secondary_colour_column_name").ok_or_else(|| Error::from(ErrorKind::ToolVarNotFoundForGame("faction_painter_uniform_secondary_colour_column_name".to_owned())))?;
        let uniform_tertiary_colour_column_name = GAME_SELECTED.read().unwrap().get_tool_var("faction_painter_uniform_tertiary_colour_column_name").ok_or_else(|| Error::from(ErrorKind::ToolVarNotFoundForGame("faction_painter_uniform_tertiary_colour_column_name".to_owned())))?;
        if let Some(first) = data.iter().next() {
            if let Some(definition) = first.get(table_definition_name) {
                let mut table = DB::new(&table_name, None, &serde_json::from_str(definition)?);
                let banner_primary_colour_column = table.get_column_position_by_name(banner_primary_colour_column_name)?;
                let banner_secondary_colour_column = table.get_column_position_by_name(banner_secondary_colour_column_name)?;
                let banner_tertiary_colour_column = table.get_column_position_by_name(banner_tertiary_colour_column_name)?;
                let uniform_primary_colour_column = table.get_column_position_by_name(uniform_primary_colour_column_name)?;
                let uniform_secondary_colour_column = table.get_column_position_by_name(uniform_secondary_colour_column_name)?;
                let uniform_tertiary_colour_column = table.get_column_position_by_name(uniform_tertiary_colour_column_name)?;
                let table_data = data.par_iter()
                    .filter_map(|row_data| {
                        let row = row_data.get(row_key)?;
                        let mut row: Vec<DecodedData> = serde_json::from_str(row).ok()?;
                        let mut save_row = false;
                        if row_data.get("banner_primary").is_some() {
                            let banner_primary = u32::from_str_radix(row_data.get("banner_primary")?, 16).ok()?;
                            let banner_secondary = u32::from_str_radix(row_data.get("banner_secondary")?, 16).ok()?;
                            let banner_tertiary = u32::from_str_radix(row_data.get("banner_tertiary")?, 16).ok()?;
                            row[banner_primary_colour_column] = DecodedData::ColourRGB(banner_primary);
                            row[banner_secondary_colour_column] = DecodedData::ColourRGB(banner_secondary);
                            row[banner_tertiary_colour_column] = DecodedData::ColourRGB(banner_tertiary);
                            save_row = true;
                        }
                        if row_data.get("uniform_primary").is_some() {
                            let uniform_primary = u32::from_str_radix(row_data.get("uniform_primary")?, 16).ok()?;
                            let uniform_secondary = u32::from_str_radix(row_data.get("uniform_secondary")?, 16).ok()?;
                            let uniform_tertiary = u32::from_str_radix(row_data.get("uniform_tertiary")?, 16).ok()?;
                            row[uniform_primary_colour_column] = DecodedData::ColourRGB(uniform_primary);
                            row[uniform_secondary_colour_column] = DecodedData::ColourRGB(uniform_secondary);
                            row[uniform_tertiary_colour_column] = DecodedData::ColourRGB(uniform_tertiary);
                            save_row = true;
                        }
                        if save_row {
                            Some(row)
                        } else {
                            None
                        }
                    }).collect::<Vec<Vec<DecodedData>>>();
                table.set_table_data(&table_data)?;
                let path = vec!["db".to_owned(), table_name.to_owned(), self.get_file_name()];
                Ok(PackedFile::new_from_decoded(&DecodedPackedFile::DB(table), &path))
            } else { Err(ErrorKind::Impossibru.into()) }
        } else { Err(ErrorKind::Impossibru.into()) }
    }
unsafe fn save_factions_data ( & self , data : & [ HashMap < String , String > ] ) -> Result < PackedFile > { let table_name = GAME_SELECTED . read ( ) . unwrap ( ) . get_tool_var ( " " ) . ok_or_else ( | | Error :: from ( ErrorKind :: ToolVarNotFoundForGame ( " " . to_owned ( ) ) ) ) ? ; let table_definition_name = GAME_SELECTED . read ( ) . unwrap ( ) . get_tool_var ( " " ) . ok_or_else ( | | Error :: from ( ErrorKind :: ToolVarNotFoundForGame ( " " . to_owned ( ) ) ) ) ? ; let row_key = GAME_SELECTED . read ( ) . unwrap ( ) . get_tool_var ( " " ) . ok_or_else ( | | Error :: from ( ErrorKind :: ToolVarNotFoundForGame ( " " . to_owned ( ) ) ) ) ? ; let banner_primary_colour_column_name = GAME_SELECTED . read ( ) . unwrap ( ) . get_tool_var ( " " ) . ok_or_else ( | | Error :: from ( ErrorKind :: ToolVarNotFoundForGame ( " " . to_owned ( ) ) ) ) ? ; let banner_secondary_colour_column_name = GAME_SELECTED . read ( ) . unwrap ( ) . get_tool_var ( " " ) . ok_or_else ( | | Error :: from ( ErrorKind :: ToolVarNotFoundForGame ( " " . to_owned ( ) ) ) ) ? ; let banner_tertiary_colour_column_name = GAME_SELECTED . read ( ) . unwrap ( ) . get_tool_var ( " " ) . ok_or_else ( | | Error :: from ( ErrorKind :: ToolVarNotFoundForGame ( " " . to_owned ( ) ) ) ) ? ; let uniform_primary_colour_column_name = GAME_SELECTED . read ( ) . unwrap ( ) . get_tool_var ( " " ) . ok_or_else ( | | Error :: from ( ErrorKind :: ToolVarNotFoundForGame ( " " . to_owned ( ) ) ) ) ? ; let uniform_secondary_colour_column_name = GAME_SELECTED . read ( ) . unwrap ( ) . get_tool_var ( " " ) . ok_or_else ( | | Error :: from ( ErrorKind :: ToolVarNotFoundForGame ( " " . to_owned ( ) ) ) ) ? ; let uniform_tertiary_colour_column_name = GAME_SELECTED . read ( ) . unwrap ( ) . get_tool_var ( " " ) . ok_or_else ( | | Error :: from ( ErrorKind :: ToolVarNotFoundForGame ( " " . to_owned ( ) ) ) ) ? ; if let Some ( first ) = data . iter ( ) . next ( ) { if let Some ( definition ) = first . get ( table_definition_name ) { let mut table = DB :: new ( & table_name , None , & serde_json :: from_str ( definition ) ? ) ; let banner_primary_colour_column = table . get_column_position_by_name ( banner_primary_colour_column_name ) ? ; let banner_secondary_colour_column = table . get_column_position_by_name ( banner_secondary_colour_column_name ) ? ; let banner_tertiary_colour_column = table . get_column_position_by_name ( banner_tertiary_colour_column_name ) ? ; let uniform_primary_colour_column = table . get_column_position_by_name ( uniform_primary_colour_column_name ) ? ; let uniform_secondary_colour_column = table . get_column_position_by_name ( uniform_secondary_colour_column_name ) ? ; let uniform_tertiary_colour_column = table . get_column_position_by_name ( uniform_tertiary_colour_column_name ) ? ; let table_data = data . par_iter ( ) . filter_map ( | row_data | { let row = row_data . get ( row_key ) ? ; let mut row : Vec < DecodedData > = serde_json :: from_str ( row ) . ok ( ) ? ; let mut save_row = false ; if row_data . get ( " " ) . is_some ( ) { let banner_primary = u32 :: from_str_radix ( row_data . get ( " " ) ? , 16 ) . ok ( ) ? ; let banner_secondary = u32 :: from_str_radix ( row_data . get ( " " ) ? , 16 ) . ok ( ) ? ; let banner_tertiary = u32 :: from_str_radix ( row_data . get ( " " ) ? , 16 ) . ok ( ) ? ; row [ banner_primary_colour_column ] = DecodedData :: ColourRGB ( banner_primary ) ; row [ banner_secondary_colour_column ] = DecodedData :: ColourRGB ( banner_secondary ) ; row [ banner_tertiary_colour_column ] = DecodedData :: ColourRGB ( banner_tertiary ) ; save_row = true ; } if row_data . get ( " " ) . is_some ( ) { let uniform_primary = u32 :: from_str_radix ( row_data . get ( " " ) ? , 16 ) . ok ( ) ? ; let uniform_secondary = u32 :: from_str_radix ( row_data . get ( " " ) ? , 16 ) . ok ( ) ? ; let uniform_tertiary = u32 :: from_str_radix ( row_data . get ( " " ) ? , 16 ) . ok ( ) ? ; row [ uniform_primary_colour_column ] = DecodedData :: ColourRGB ( uniform_primary ) ; row [ uniform_secondary_colour_column ] = DecodedData :: ColourRGB ( uniform_secondary ) ; row [ uniform_tertiary_colour_column ] = DecodedData :: ColourRGB ( uniform_tertiary ) ; save_row = true ; } if save_row { Some ( row ) } else { None } } ) . collect :: < Vec < Vec < DecodedData > > > ( ) ; table . set_table_data ( & table_data ) ? ; let path = vec ! [ " " to_owned ( ) table_name to_owned ( ) self get_file_name ( ) ] ; Ok ( PackedFile :: new_from_decoded ( & DecodedPackedFile :: DB ( table ) , & path ) ) } else { Err ( ErrorKind :: Impossibru . into ( ) ) } } else { Err ( ErrorKind :: Impossibru . into ( ) ) } }
This function takes care of saving the factions's data into a PackedFile.
This function takes care of saving the factions ' s data into a PackedFile .
&self
data
&[HashMap<String, String>]
&self
data
&[HashMap<String, String>]