fn from_struct(
        config_path: PathBuf,
        config_file: ConfigFile,
        validate_fs: bool,
    ) -> Result<Self> {
        let mut hash = Sha1::new();
        serde_json::to_writer(&mut hash, &config_file).unwrap();

        let projects = config_file
            .projects
            .into_iter()
            .map(|(project_name, config_file_project)| {
                let schema_location =
                    match (config_file_project.schema, config_file_project.schema_dir) {
                        (Some(schema_file), None) => Ok(SchemaLocation::File(schema_file)),
                        (None, Some(schema_dir)) => Ok(SchemaLocation::Directory(schema_dir)),
                        _ => Err(Error::ConfigFileValidation {
                            config_path: config_path.clone(),
                            validation_errors: vec![
                                ConfigValidationError::ProjectNeedsSchemaXorSchemaDir {
                                    project_name,
                                },
                            ],
                        }),
                    }?;

                let shard_strip_regex = match config_file_project.shard_strip_regex {
                    None => Ok(None),
                    Some(ref val) => match Regex::new(val) {
                        Ok(val) => Ok(Some(val)),
                        Err(error) => Err(Error::ConfigFileValidation {
                            config_path: config_path.clone(),
                            validation_errors: vec![
                                ConfigValidationError::InvalidShardPathStripRegex {
                                    project_name,
                                    error,
                                },
                            ],
                        }),
                    },
                }?;

                let project_config = ProjectConfig {
                    name: project_name,
                    base: config_file_project.base,
                    enabled: true,
                    extensions: config_file_project.extensions,
                    output: config_file_project.output,
                    extra_artifacts_output: config_file_project.extra_artifacts_output,
                    shard_output: config_file_project.shard_output,
                    shard_strip_regex,
                    schema_location,
                    typegen_config: config_file_project.typegen_config,
                    persist: config_file_project.persist,
                    variable_names_comment: config_file_project.variable_names_comment,
                    extra: config_file_project.extra,
                    feature_flags: config_file_project.feature_flags,
                    filename_for_artifact: None,
                    skip_types_for_artifact: None,
                    rollout: config_file_project.rollout,
                    js_module_format: config_file_project.js_module_format,
                };
                Ok((project_name, project_config))
            })
            .collect::<Result<FnvIndexMap<_, _>>>()?;

        let config_file_dir = config_path.parent().unwrap();
        let root_dir = if let Some(config_root) = config_file.root {
            config_file_dir.join(config_root).canonicalize().unwrap()
        } else {
            config_file_dir.to_owned()
        };

        let config = Self {
            name: config_file.name,
            artifact_writer: Box::new(ArtifactFileWriter::new(None, root_dir.clone())),
            status_reporter: Box::new(ConsoleStatusReporter::new(root_dir.clone())),
            root_dir,
            sources: config_file.sources,
            excludes: config_file.excludes,
            projects,
            header: config_file.header,
            codegen_command: config_file.codegen_command,
            load_saved_state_file: None,
            generate_extra_artifacts: None,
            saved_state_config: config_file.saved_state_config,
            saved_state_loader: None,
            saved_state_version: hex::encode(hash.result()),
            connection_interface: config_file.connection_interface,
            feature_flags: config_file.feature_flags,
            operation_persister: None,
            compile_everything: false,
            repersist_operations: false,
            post_artifacts_write: None,
            additional_validations: None,
            is_dev_variable_name: config_file.is_dev_variable_name,
        };

        let mut validation_errors = Vec::new();
        config.validate_consistency(&mut validation_errors);
        if validate_fs {
            config.validate_paths(&mut validation_errors);
        }
        if validation_errors.is_empty() {
            Ok(config)
        } else {
            Err(Error::ConfigFileValidation {
                config_path,
                validation_errors,
            })
        }
    }
/// `validate_fs` disables all filesystem checks for existence of files
`validate_fs` disables all filesystem checks for existence of files
` validate_fs ` disables all filesystem checks for existence of files
fn from_struct(
        config_path: PathBuf,
        config_file: ConfigFile,
        validate_fs: bool,
    ) -> Result<Self> {
        let mut hash = Sha1::new();
        serde_json::to_writer(&mut hash, &config_file).unwrap();
        let projects = config_file
            .projects
            .into_iter()
            .map(|(project_name, config_file_project)| {
                let schema_location =
                    match (config_file_project.schema, config_file_project.schema_dir) {
                        (Some(schema_file), None) => Ok(SchemaLocation::File(schema_file)),
                        (None, Some(schema_dir)) => Ok(SchemaLocation::Directory(schema_dir)),
                        _ => Err(Error::ConfigFileValidation {
                            config_path: config_path.clone(),
                            validation_errors: vec![
                                ConfigValidationError::ProjectNeedsSchemaXorSchemaDir {
                                    project_name,
                                },
                            ],
                        }),
                    }?;
                let shard_strip_regex = match config_file_project.shard_strip_regex {
                    None => Ok(None),
                    Some(ref val) => match Regex::new(val) {
                        Ok(val) => Ok(Some(val)),
                        Err(error) => Err(Error::ConfigFileValidation {
                            config_path: config_path.clone(),
                            validation_errors: vec![
                                ConfigValidationError::InvalidShardPathStripRegex {
                                    project_name,
                                    error,
                                },
                            ],
                        }),
                    },
                }?;
                let project_config = ProjectConfig {
                    name: project_name,
                    base: config_file_project.base,
                    enabled: true,
                    extensions: config_file_project.extensions,
                    output: config_file_project.output,
                    extra_artifacts_output: config_file_project.extra_artifacts_output,
                    shard_output: config_file_project.shard_output,
                    shard_strip_regex,
                    schema_location,
                    typegen_config: config_file_project.typegen_config,
                    persist: config_file_project.persist,
                    variable_names_comment: config_file_project.variable_names_comment,
                    extra: config_file_project.extra,
                    feature_flags: config_file_project.feature_flags,
                    filename_for_artifact: None,
                    skip_types_for_artifact: None,
                    rollout: config_file_project.rollout,
                    js_module_format: config_file_project.js_module_format,
                };
                Ok((project_name, project_config))
            })
            .collect::<Result<FnvIndexMap<_, _>>>()?;
        let config_file_dir = config_path.parent().unwrap();
        let root_dir = if let Some(config_root) = config_file.root {
            config_file_dir.join(config_root).canonicalize().unwrap()
        } else {
            config_file_dir.to_owned()
        };
        let config = Self {
            name: config_file.name,
            artifact_writer: Box::new(ArtifactFileWriter::new(None, root_dir.clone())),
            status_reporter: Box::new(ConsoleStatusReporter::new(root_dir.clone())),
            root_dir,
            sources: config_file.sources,
            excludes: config_file.excludes,
            projects,
            header: config_file.header,
            codegen_command: config_file.codegen_command,
            load_saved_state_file: None,
            generate_extra_artifacts: None,
            saved_state_config: config_file.saved_state_config,
            saved_state_loader: None,
            saved_state_version: hex::encode(hash.result()),
            connection_interface: config_file.connection_interface,
            feature_flags: config_file.feature_flags,
            operation_persister: None,
            compile_everything: false,
            repersist_operations: false,
            post_artifacts_write: None,
            additional_validations: None,
            is_dev_variable_name: config_file.is_dev_variable_name,
        };
        let mut validation_errors = Vec::new();
        config.validate_consistency(&mut validation_errors);
        if validate_fs {
            config.validate_paths(&mut validation_errors);
        }
        if validation_errors.is_empty() {
            Ok(config)
        } else {
            Err(Error::ConfigFileValidation {
                config_path,
                validation_errors,
            })
        }
    }
fn from_struct ( config_path : PathBuf , config_file : ConfigFile , validate_fs : bool , ) -> Result < Self > { let mut hash = Sha1 :: new ( ) ; serde_json :: to_writer ( & mut hash , & config_file ) . unwrap ( ) ; let projects = config_file . projects . into_iter ( ) . map ( | ( project_name , config_file_project ) | { let schema_location = match ( config_file_project . schema , config_file_project . schema_dir ) { ( Some ( schema_file ) , None ) => Ok ( SchemaLocation :: File ( schema_file ) ) , ( None , Some ( schema_dir ) ) => Ok ( SchemaLocation :: Directory ( schema_dir ) ) , _ => Err ( Error :: ConfigFileValidation { config_path : config_path . clone ( ) , validation_errors : vec ! [ ConfigValidationError ProjectNeedsSchemaXorSchemaDir { project_name } ] , } ) , } ? ; let shard_strip_regex = match config_file_project . shard_strip_regex { None => Ok ( None ) , Some ( ref val ) => match Regex :: new ( val ) { Ok ( val ) => Ok ( Some ( val ) ) , Err ( error ) => Err ( Error :: ConfigFileValidation { config_path : config_path . clone ( ) , validation_errors : vec ! [ ConfigValidationError InvalidShardPathStripRegex { project_name error } ] , } ) , } , } ? ; let project_config = ProjectConfig { name : project_name , base : config_file_project . base , enabled : true , extensions : config_file_project . extensions , output : config_file_project . output , extra_artifacts_output : config_file_project . extra_artifacts_output , shard_output : config_file_project . shard_output , shard_strip_regex , schema_location , typegen_config : config_file_project . typegen_config , persist : config_file_project . persist , variable_names_comment : config_file_project . variable_names_comment , extra : config_file_project . extra , feature_flags : config_file_project . feature_flags , filename_for_artifact : None , skip_types_for_artifact : None , rollout : config_file_project . rollout , js_module_format : config_file_project . js_module_format , } ; Ok ( ( project_name , project_config ) ) } ) . collect :: < Result < FnvIndexMap < _ , _ > > > ( ) ? ; let config_file_dir = config_path . parent ( ) . unwrap ( ) ; let root_dir = if let Some ( config_root ) = config_file . root { config_file_dir . join ( config_root ) . canonicalize ( ) . unwrap ( ) } else { config_file_dir . to_owned ( ) } ; let config = Self { name : config_file . name , artifact_writer : Box :: new ( ArtifactFileWriter :: new ( None , root_dir . clone ( ) ) ) , status_reporter : Box :: new ( ConsoleStatusReporter :: new ( root_dir . clone ( ) ) ) , root_dir , sources : config_file . sources , excludes : config_file . excludes , projects , header : config_file . header , codegen_command : config_file . codegen_command , load_saved_state_file : None , generate_extra_artifacts : None , saved_state_config : config_file . saved_state_config , saved_state_loader : None , saved_state_version : hex :: encode ( hash . result ( ) ) , connection_interface : config_file . connection_interface , feature_flags : config_file . feature_flags , operation_persister : None , compile_everything : false , repersist_operations : false , post_artifacts_write : None , additional_validations : None , is_dev_variable_name : config_file . is_dev_variable_name , } ; let mut validation_errors = Vec :: new ( ) ; config . validate_consistency ( & mut validation_errors ) ; if validate_fs { config . validate_paths ( & mut validation_errors ) ; } if validation_errors . is_empty ( ) { Ok ( config ) } else { Err ( Error :: ConfigFileValidation { config_path , validation_errors , } ) } }
`validate_fs` disables all filesystem checks for existence of files
` validate_fs ` disables all filesystem checks for existence of files
config_path
PathBuf
config_file
ConfigFile
validate_fs
bool
config_path
PathBuf
config_file
ConfigFile
validate_fs
bool