INNER CODE UNIT · Rust

parse_threads

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

fn parse_threads(value: &str) -> Result<usize, String> {
    match value.parse::<u8>() {
        Ok(0) => Err("Not positive number".to_owned()),
        Ok(value) => Ok(value as usize),
        Err(err) => Err(err.to_string()),
    }
}

fn parse_upload_size_limit(value: &str) -> Result<u64, String> {
    let trimmed = value.trim();
    if trimmed.is_empty() {
        return Err("size limit can not be empty".to_owned());
    }

    let suffix_start = trimmed
        .find(|ch: char| !ch.is_ascii_digit())
        .unwrap_or(trimmed.len());
    let (number, suffix) = trimmed.split_at(suffix_start);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…