fn parse_chunk_size()

in below/src/main.rs [108:126]


fn parse_chunk_size(s: &str) -> Result<u32> {
    let x = s
        .parse::<u32>()
        .with_context(|| format!("{} cannot be parsed as a u32", s))?;
    if x <= 1 {
        bail!("{} is less than the minimum chunk size of 2", x);
    }
    if x.count_ones() != 1 {
        bail!("{} is not a power of two", x);
    }
    if x > store::MAX_CHUNK_COMPRESS_SIZE {
        bail!(
            "{} is greater than the maximimum supported chunk size of {}",
            x,
            store::MAX_CHUNK_COMPRESS_SIZE
        );
    }
    Ok(x)
}