fn make_log_segment_max_bytes(file_cfg: &Option<SpuConfigFile>) -> Result<u32, IoError> {
        let mut log_segment_max_bytes = None;

        // 1) environment variable (optional field, ignore errors)
        if let Ok(log_segment_max_bytes_str) = env::var(FLV_LOG_SEGMENT_MAX_BYTES) {
            let segment_max_bytes: u32 = log_segment_max_bytes_str.parse().map_err(|err| {
                IoError::new(
                    ErrorKind::InvalidInput,
                    format!("log segment_max_bytes: {}", err),
                )
            })?;
            log_segment_max_bytes = Some(segment_max_bytes);
        }

        // 2) config file
        if log_segment_max_bytes.is_none() && file_cfg.is_some() {
            log_segment_max_bytes = file_cfg.as_ref().unwrap().log_segment_max_bytes();
        }

        // 3) unwrap or use default
        Ok(log_segment_max_bytes.unwrap_or(SPU_LOG_SEGMENT_MAX_BYTES))
    }
/// Generate log segment_max_bytes by combining all config elements. Returns error on failure.
Generate log segment_max_bytes by combining all config elements. Returns error on failure.
Generate log segment_max_bytes by combining all config elements . Returns error on failure .
fn make_log_segment_max_bytes(file_cfg: &Option<SpuConfigFile>) -> Result<u32, IoError> {
        let mut log_segment_max_bytes = None;
        // 1) environment variable (optional field, ignore errors)
        if let Ok(log_segment_max_bytes_str) = env::var(FLV_LOG_SEGMENT_MAX_BYTES) {
            let segment_max_bytes: u32 = log_segment_max_bytes_str.parse().map_err(|err| {
                IoError::new(
                    ErrorKind::InvalidInput,
                    format!("log segment_max_bytes: {}", err),
                )
            })?;
            log_segment_max_bytes = Some(segment_max_bytes);
        }
        // 2) config file
        if log_segment_max_bytes.is_none() && file_cfg.is_some() {
            log_segment_max_bytes = file_cfg.as_ref().unwrap().log_segment_max_bytes();
        }
        // 3) unwrap or use default
        Ok(log_segment_max_bytes.unwrap_or(SPU_LOG_SEGMENT_MAX_BYTES))
    }
fn make_log_segment_max_bytes ( file_cfg : & Option < SpuConfigFile > ) -> Result < u32 , IoError > { let mut log_segment_max_bytes = None ; // 1) environment variable (optional field, ignore errors) if let Ok ( log_segment_max_bytes_str ) = env :: var ( FLV_LOG_SEGMENT_MAX_BYTES ) { let segment_max_bytes : u32 = log_segment_max_bytes_str . parse ( ) . map_err ( | err | { IoError :: new ( ErrorKind :: InvalidInput , format ! ( " " err ) , ) } ) ? ; log_segment_max_bytes = Some ( segment_max_bytes ) ; } // 2) config file if log_segment_max_bytes . is_none ( ) && file_cfg . is_some ( ) { log_segment_max_bytes = file_cfg . as_ref ( ) . unwrap ( ) . log_segment_max_bytes ( ) ; } // 3) unwrap or use default Ok ( log_segment_max_bytes . unwrap_or ( SPU_LOG_SEGMENT_MAX_BYTES ) ) }
Generate log segment_max_bytes by combining all config elements.
Generate log segment_max_bytes by combining all config elements .
file_cfg
&Option<SpuConfigFile>
file_cfg
&Option<SpuConfigFile>