pub fn build_schema_dir(
    source: impl AsRef<Path>,
    destination: impl AsRef<Path>,
    config: &BuildConfig,
) {
    if !destination.as_ref().exists() {
        fs::create_dir_all(destination.as_ref()).unwrap();
    }

    // clean all previously built files
    fs::read_dir(destination.as_ref())
        .unwrap()
        .filter_map(|entry| {
            let entry = entry.unwrap();
            let name = entry.file_name().to_str().unwrap().to_string();
            if entry.file_type().unwrap().is_file() && name != "mod.rs" {
                Some(name)
            } else {
                None
            }
        })
        .for_each(|file| fs::remove_file(PathBuf::from(destination.as_ref()).join(file)).unwrap());

    // build all files and update lib.rs
    let files = recurse_schema_dir(source, destination.as_ref(), config);

    // update the mod file
    if config.generate_module_file {
        let mod_file_path = PathBuf::from(destination.as_ref()).join("mod.rs");
        fs::write(
            &mod_file_path,
            &files
                .into_iter()
                .map(|mut schema_name| {
                    schema_name.insert_str(0, "pub mod ");
                    schema_name.push(';');
                    schema_name.push('\n');
                    schema_name
                })
                .collect::<String>(),
        )
        .unwrap();

        #[cfg(feature = "format")]
        if config.format_files {
            fmt_file(mod_file_path);
        }
    }
}
/// Build all schemas in a given directory and write them to the destination directory including a
/// `mod.rs` file.
///
/// **WARNING: THIS DELETES DATA IN THE DESTINATION DIRECTORY** use something like `src/bebop` or `src/generated`.
Build all schemas in a given directory and write them to the destination directory including a
`mod.rs` file.


Build all schemas in a given directory and write them to the destination directory including a ` mod . rs ` file .
pub fn build_schema_dir(
    source: impl AsRef<Path>,
    destination: impl AsRef<Path>,
    config: &BuildConfig,
) {
    if !destination.as_ref().exists() {
        fs::create_dir_all(destination.as_ref()).unwrap();
    }
    // clean all previously built files
    fs::read_dir(destination.as_ref())
        .unwrap()
        .filter_map(|entry| {
            let entry = entry.unwrap();
            let name = entry.file_name().to_str().unwrap().to_string();
            if entry.file_type().unwrap().is_file() && name != "mod.rs" {
                Some(name)
            } else {
                None
            }
        })
        .for_each(|file| fs::remove_file(PathBuf::from(destination.as_ref()).join(file)).unwrap());
    // build all files and update lib.rs
    let files = recurse_schema_dir(source, destination.as_ref(), config);
    // update the mod file
    if config.generate_module_file {
        let mod_file_path = PathBuf::from(destination.as_ref()).join("mod.rs");
        fs::write(
            &mod_file_path,
            &files
                .into_iter()
                .map(|mut schema_name| {
                    schema_name.insert_str(0, "pub mod ");
                    schema_name.push(';');
                    schema_name.push('\n');
                    schema_name
                })
                .collect::<String>(),
        )
        .unwrap();
        #[cfg(feature = "format")]
        if config.format_files {
            fmt_file(mod_file_path);
        }
    }
}
pub fn build_schema_dir ( source : impl AsRef < Path > , destination : impl AsRef < Path > , config : & BuildConfig , ) { if ! destination . as_ref ( ) . exists ( ) { fs :: create_dir_all ( destination . as_ref ( ) ) . unwrap ( ) ; } // clean all previously built files fs :: read_dir ( destination . as_ref ( ) ) . unwrap ( ) . filter_map ( | entry | { let entry = entry . unwrap ( ) ; let name = entry . file_name ( ) . to_str ( ) . unwrap ( ) . to_string ( ) ; if entry . file_type ( ) . unwrap ( ) . is_file ( ) && name != " " { Some ( name ) } else { None } } ) . for_each ( | file | fs :: remove_file ( PathBuf :: from ( destination . as_ref ( ) ) . join ( file ) ) . unwrap ( ) ) ; // build all files and update lib.rs let files = recurse_schema_dir ( source , destination . as_ref ( ) , config ) ; // update the mod file if config . generate_module_file { let mod_file_path = PathBuf :: from ( destination . as_ref ( ) ) . join ( " " ) ; fs :: write ( & mod_file_path , & files . into_iter ( ) . map ( | mut schema_name | { schema_name . insert_str ( 0 , " " ) ; schema_name . push ( ';' ) ; schema_name . push ( '\n' ) ; schema_name } ) . collect :: < String > ( ) , ) . unwrap ( ) ; # [ cfg ( feature " " ) ] if config . format_files { fmt_file ( mod_file_path ) ; } } }
Build all schemas in a given directory and write them to the destination directory including a
`mod.rs` file.
Build all schemas in a given directory and write them to the destination directory including a ` mod . rs ` file .
source
impl AsRef<Path>
destination
impl AsRef<Path>
config
&BuildConfig