pub fn save(&mut self, schema_file: &str) -> Result<()> {
        let mut file_path = get_config_path()?.join(SCHEMA_FOLDER);

        // Make sure the path exists to avoid problems with updating schemas.
        DirBuilder::new().recursive(true).create(&file_path)?;

        file_path.push(schema_file);
        let mut file = File::create(&file_path)?;
        let config = PrettyConfig::default();

        self.sort();

        // Make sure all definitions are properly sorted.
        self.versioned_files.iter_mut().for_each(|x| {
            match x {
                VersionedFileV3::AnimFragment(ref mut versions) |
                VersionedFileV3::AnimTable(ref mut versions) |
                VersionedFileV3::DB(_, ref mut versions) |
                VersionedFileV3::DepManager(ref mut versions) |
                VersionedFileV3::Loc(ref mut versions) |
                VersionedFileV3::MatchedCombat(ref mut versions) => {
                    // Sort them by version number.
                    versions.sort_by(|a, b| b.get_version().cmp(&a.get_version()));
                }
            }
        });
        file.write_all(to_string_pretty(&self, config)?.as_bytes())?;
        Ok(())
    }
/// This function saves a `Schema` from memory to a file in the `schemas/` folder.
This function saves a `Schema` from memory to a file in the `schemas/` folder.
This function saves a ` Schema ` from memory to a file in the ` schemas / ` folder .
pub fn save(&mut self, schema_file: &str) -> Result<()> {
        let mut file_path = get_config_path()?.join(SCHEMA_FOLDER);
        // Make sure the path exists to avoid problems with updating schemas.
        DirBuilder::new().recursive(true).create(&file_path)?;
        file_path.push(schema_file);
        let mut file = File::create(&file_path)?;
        let config = PrettyConfig::default();
        self.sort();
        // Make sure all definitions are properly sorted.
        self.versioned_files.iter_mut().for_each(|x| {
            match x {
                VersionedFileV3::AnimFragment(ref mut versions) |
                VersionedFileV3::AnimTable(ref mut versions) |
                VersionedFileV3::DB(_, ref mut versions) |
                VersionedFileV3::DepManager(ref mut versions) |
                VersionedFileV3::Loc(ref mut versions) |
                VersionedFileV3::MatchedCombat(ref mut versions) => {
                    // Sort them by version number.
                    versions.sort_by(|a, b| b.get_version().cmp(&a.get_version()));
                }
            }
        });
        file.write_all(to_string_pretty(&self, config)?.as_bytes())?;
        Ok(())
    }
pub fn save ( & mut self , schema_file : & str ) -> Result < ( ) > { let mut file_path = get_config_path ( ) ? . join ( SCHEMA_FOLDER ) ; // Make sure the path exists to avoid problems with updating schemas. DirBuilder :: new ( ) . recursive ( true ) . create ( & file_path ) ? ; file_path . push ( schema_file ) ; let mut file = File :: create ( & file_path ) ? ; let config = PrettyConfig :: default ( ) ; self . sort ( ) ; // Make sure all definitions are properly sorted. self . versioned_files . iter_mut ( ) . for_each ( | x | { match x { VersionedFileV3 :: AnimFragment ( ref mut versions ) | VersionedFileV3 :: AnimTable ( ref mut versions ) | VersionedFileV3 :: DB ( _ , ref mut versions ) | VersionedFileV3 :: DepManager ( ref mut versions ) | VersionedFileV3 :: Loc ( ref mut versions ) | VersionedFileV3 :: MatchedCombat ( ref mut versions ) => { // Sort them by version number. versions . sort_by ( | a , b | b . get_version ( ) . cmp ( & a . get_version ( ) ) ) ; } } } ) ; file . write_all ( to_string_pretty ( & self , config ) ? . as_bytes ( ) ) ? ; Ok ( ( ) ) }
This function saves a `Schema` from memory to a file in the `schemas/` folder.
This function saves a ` Schema ` from memory to a file in the ` schemas / ` folder .
&mut self
schema_file
&str
&mut self
schema_file
&str