INNER CODE UNIT · Rust

parse_redirect_url

TheWaWaR/simple-http-server · src/config.rs:461

fn parse_redirect_url(value: &str) -> Result<String, String> {
    let uri = Uri::from_str(value).map_err(|err| err.to_string())?;
    if uri.scheme_str().is_some() && uri.authority().is_some() {
        Ok(value.to_owned())
    } else {
        Err("URL must be absolute".to_owned())
    }
}

fn parse_ip_addr(value: &str) -> Result<IpAddr, String> {
    IpAddr::from_str(value).map_err(|err| err.to_string())
}

fn parse_port(value: &str) -> Result<u16, String> {
    value.parse::<u16>().map_err(|err| err.to_string())
}

fn parse_threads(value: &str) -> Result<usize, String> {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…