bytesize icon indicating copy to clipboard operation
bytesize copied to clipboard

Feature Request: Bits

Open acheronfail opened this issue 2 years ago • 2 comments

I'm using this in a network monitor context, and it's very nice to have automatic formatting into *bytes/sec - which is commonly used in things like download speeds in browsers, etc.

However, it's also very common to measure internet bandwidth in bits, i.e., a "100 megabit connection" or "100 Mbps".

I think it would be really neat if this crate could support a Bit type too, so it could format in bits as well as bytes.

acheronfail avatar May 11 '23 16:05 acheronfail

Right now this is a workaround:

fn bits(bytes: u64, si: bool) -> String {
    let mut s = ByteSize(bytes * 8).to_string_as(si);
    s.pop();
    format!("{}bits", s)
}

acheronfail avatar May 23 '23 04:05 acheronfail