/// Creates a base config from a config file.
///
/// This functions prints all its error messages directly to stderr.
Creates a base config from a config file.
This functions prints all its error messages directly to stderr.
Creates a base config from a config file . This functions prints all its error messages directly to stderr .
fn from_config_file(mut file: ConfigFile) -> Result<Self, Error> {
        let log_target = Self::log_target_from_config_file(&mut file)?;
        let res = Config {
            cache_dir: file.take_mandatory_path("repository-dir")?,
            tal_dir: file.take_mandatory_path("tal-dir")?,
            exceptions: file.take_path_array("exceptions")?,
            strict: file.take_bool("strict")?.unwrap_or(false),
            rsync_command: {
                file.take_string("rsync-command")?
                    .unwrap_or_else(|| "rsync".into())
            },
            rsync_args: file.take_opt_string_array("rsync-args")?,
            rsync_count: {
                file.take_small_usize("rsync-count")?
                    .unwrap_or(DEFAULT_RSYNC_COUNT)
            },
            rsync_timeout: {
                Duration::from_secs(
                    file.take_u64("rsync-timeout")?
                        .unwrap_or(DEFAULT_RSYNC_TIMEOUT)
                )
            },
            validation_threads: {
                file.take_small_usize("validation-threads")?
                    .unwrap_or_else(::num_cpus::get)
            },
            refresh: {
                Duration::from_secs(
                    file.take_u64("refresh")?.unwrap_or(DEFAULT_REFRESH)
                )
            },
            retry: {
                Duration::from_secs(
                    file.take_u64("retry")?.unwrap_or(DEFAULT_RETRY)
                )
            },
            expire: {
                Duration::from_secs(
                    file.take_u64("expire")?.unwrap_or(DEFAULT_EXPIRE)
                )
            },
            history_size: {
                file.take_small_usize("history-size")?
                    .unwrap_or(DEFAULT_HISTORY_SIZE)
            },
            tcp_listen: {
                file.take_from_str_array("listen-tcp")?
                    .unwrap_or_else(Self::default_tcp_listen)
            },
            http_listen: {
                file.take_from_str_array("listen-http")?
                    .unwrap_or_else(Vec::new)
            },
            log_level: {
                file.take_from_str("log-level")?.unwrap_or(LevelFilter::Warn)
            },
            log_target,
            pid_file: file.take_path("pid-file")?,
            working_dir: file.take_path("working-dir")?,
            chroot: file.take_path("chroot")?,
        };
        file.check_exhausted()?;
        Ok(res)
    }
fn from_config_file ( mut file : ConfigFile ) -> Result < Self , Error > { let log_target = Self :: log_target_from_config_file ( & mut file ) ? ; let res = Config { cache_dir : file . take_mandatory_path ( " " ) ? , tal_dir : file . take_mandatory_path ( " " ) ? , exceptions : file . take_path_array ( " " ) ? , strict : file . take_bool ( " " ) ? . unwrap_or ( false ) , rsync_command : { file . take_string ( " " ) ? . unwrap_or_else ( | | " " . into ( ) ) } , rsync_args : file . take_opt_string_array ( " " ) ? , rsync_count : { file . take_small_usize ( " " ) ? . unwrap_or ( DEFAULT_RSYNC_COUNT ) } , rsync_timeout : { Duration :: from_secs ( file . take_u64 ( " " ) ? . unwrap_or ( DEFAULT_RSYNC_TIMEOUT ) ) } , validation_threads : { file . take_small_usize ( " " ) ? . unwrap_or_else ( :: num_cpus :: get ) } , refresh : { Duration :: from_secs ( file . take_u64 ( " " ) ? . unwrap_or ( DEFAULT_REFRESH ) ) } , retry : { Duration :: from_secs ( file . take_u64 ( " " ) ? . unwrap_or ( DEFAULT_RETRY ) ) } , expire : { Duration :: from_secs ( file . take_u64 ( " " ) ? . unwrap_or ( DEFAULT_EXPIRE ) ) } , history_size : { file . take_small_usize ( " " ) ? . unwrap_or ( DEFAULT_HISTORY_SIZE ) } , tcp_listen : { file . take_from_str_array ( " " ) ? . unwrap_or_else ( Self :: default_tcp_listen ) } , http_listen : { file . take_from_str_array ( " " ) ? . unwrap_or_else ( Vec :: new ) } , log_level : { file . take_from_str ( " " ) ? . unwrap_or ( LevelFilter :: Warn ) } , log_target , pid_file : file . take_path ( " " ) ? , working_dir : file . take_path ( " " ) ? , chroot : file . take_path ( " " ) ? , } ; file . check_exhausted ( ) ? ; Ok ( res ) }
Creates a base config from a config file.
Creates a base config from a config file .
file
ConfigFile