fn make_private_endpoint(
        cli_cfg: &SpuOpt,
        file_cfg: &Option<SpuConfigFile>,
    ) -> Result<Endpoint, IoError> {
        // 1) check cli and convert to server address
        let mut private_ep = server_str_to_server_addr(&cli_cfg.private_server)?;

        // 2) environment variable (optional field, ignore errors)
        if private_ep.is_none() {
            if let Ok(host) = env::var(FLV_SPU_PRIVATE_HOST) {
                if let Ok(port_str) = env::var(FLV_SPU_PRIVATE_PORT) {
                    let port: u16 = port_str.parse().map_err(|err| {
                        IoError::new(
                            ErrorKind::InvalidInput,
                            format!("invalid env port: {}", err),
                        )
                    })?;
                    private_ep = Some(ServerAddress { host, port });
                }
            }
        }

        // 3) config file
        if private_ep.is_none() && file_cfg.is_some() {
            private_ep = file_cfg.as_ref().unwrap().private_endpoint();
        }

        // 4) use default
        if private_ep.is_none() {
            let host = SPU_PRIVATE_HOSTNAME.to_owned();
            let port = SPU_PRIVATE_PORT;
            private_ep = Some(ServerAddress { host, port });
        }

        // 5) create endpoint
        let ep = Endpoint::new(&private_ep.unwrap())?;

        // return result
        Ok(ep)
    }
/// Generate private_endpoint by combining all config elements. Returns error on failure.
Generate private_endpoint by combining all config elements. Returns error on failure.
Generate private_endpoint by combining all config elements . Returns error on failure .
fn make_private_endpoint(
        cli_cfg: &SpuOpt,
        file_cfg: &Option<SpuConfigFile>,
    ) -> Result<Endpoint, IoError> {
        // 1) check cli and convert to server address
        let mut private_ep = server_str_to_server_addr(&cli_cfg.private_server)?;
        // 2) environment variable (optional field, ignore errors)
        if private_ep.is_none() {
            if let Ok(host) = env::var(FLV_SPU_PRIVATE_HOST) {
                if let Ok(port_str) = env::var(FLV_SPU_PRIVATE_PORT) {
                    let port: u16 = port_str.parse().map_err(|err| {
                        IoError::new(
                            ErrorKind::InvalidInput,
                            format!("invalid env port: {}", err),
                        )
                    })?;
                    private_ep = Some(ServerAddress { host, port });
                }
            }
        }
        // 3) config file
        if private_ep.is_none() && file_cfg.is_some() {
            private_ep = file_cfg.as_ref().unwrap().private_endpoint();
        }
        // 4) use default
        if private_ep.is_none() {
            let host = SPU_PRIVATE_HOSTNAME.to_owned();
            let port = SPU_PRIVATE_PORT;
            private_ep = Some(ServerAddress { host, port });
        }
        // 5) create endpoint
        let ep = Endpoint::new(&private_ep.unwrap())?;
        // return result
        Ok(ep)
    }
fn make_private_endpoint ( cli_cfg : & SpuOpt , file_cfg : & Option < SpuConfigFile > , ) -> Result < Endpoint , IoError > { // 1) check cli and convert to server address let mut private_ep = server_str_to_server_addr ( & cli_cfg . private_server ) ? ; // 2) environment variable (optional field, ignore errors) if private_ep . is_none ( ) { if let Ok ( host ) = env :: var ( FLV_SPU_PRIVATE_HOST ) { if let Ok ( port_str ) = env :: var ( FLV_SPU_PRIVATE_PORT ) { let port : u16 = port_str . parse ( ) . map_err ( | err | { IoError :: new ( ErrorKind :: InvalidInput , format ! ( " " err ) , ) } ) ? ; private_ep = Some ( ServerAddress { host , port } ) ; } } } // 3) config file if private_ep . is_none ( ) && file_cfg . is_some ( ) { private_ep = file_cfg . as_ref ( ) . unwrap ( ) . private_endpoint ( ) ; } // 4) use default if private_ep . is_none ( ) { let host = SPU_PRIVATE_HOSTNAME . to_owned ( ) ; let port = SPU_PRIVATE_PORT ; private_ep = Some ( ServerAddress { host , port } ) ; } // 5) create endpoint let ep = Endpoint :: new ( & private_ep . unwrap ( ) ) ? ; // return result Ok ( ep ) }
Generate private_endpoint by combining all config elements.
Generate private_endpoint by combining all config elements .
cli_cfg
&SpuOpt
file_cfg
&Option<SpuConfigFile>
cli_cfg
&SpuOpt
file_cfg
&Option<SpuConfigFile>