#networking #time-duration #utility #no-std #data-structures

no-std bandwidth

A library for representing bandwidth speed in a variety of units, mimicking the core::time::Duration struct

4 releases (2 breaking)

0.3.0 Feb 10, 2023
0.2.1 Feb 9, 2023
0.2.0 Feb 9, 2023
0.1.0 Feb 8, 2023

#50 in #time-duration

Download history 4/week @ 2023-11-20 11/week @ 2024-02-19 33/week @ 2024-02-26 43/week @ 2024-03-04

87 downloads per month
Used in netem-trace

Apache-2.0

56KB
611 lines

Bandwidth

github-repo crates.io docs.rs LICENSE Apache-2.0

A library for representing bandwidth speed in a variety of units, mimicking the core::time::Duration struct.

MSRV: 1.60

This library supports no_std and serde. std are enabled by default.

Usage

More detailed usage can be found on documentation.

use bandwidth::Bandwidth;

let five_gbps = Bandwidth::from_gbps(5);
assert_eq!(five_gbps, Bandwidth::from_mbps(5_000));
assert_eq!(five_gbps, Bandwidth::from_kbps(5_000_000));
assert_eq!(five_gbps, Bandwidth::from_bps(5_000_000_000));

let ten_gbps = Bandwidth::from_gbps(10);
let seven_bps = Bandwidth::from_bps(7);
let total = ten_gbps + seven_bps;
assert_eq!(total, Bandwidth::new(10, 7));

Maintainer

@BobAnkh

How to contribute

You should follow our Code of Conduct.

See CONTRIBUTING GUIDELINES for contributing conventions.

Make sure to pass all the tests before submitting your code.

Contributors

Yixin
Yixin Shen

LICENSE

Apache-2.0 © stack-rs

Dependencies

~180KB