bytesize
bytesize copied to clipboard
Feature Request: Bits
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.
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)
}