Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Bits #30

Open
acheronfail opened this issue May 11, 2023 · 2 comments
Open

Feature Request: Bits #30

acheronfail opened this issue May 11, 2023 · 2 comments

Comments

@acheronfail
Copy link
Contributor

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
Copy link
Contributor Author

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)
}

@MrCroxx
Copy link
Collaborator

MrCroxx commented Nov 18, 2024

Hi, @acheronfail . Thanks for reporting. ByteSize uses u64 to count bytes and convert from/into u64 with bytes. Using bits as the minimal unit would break the APIs.

To support bits counting, I think we need another set of APIs. 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants