https://github.com/stack-rs/bandwidth
A library for representing bandwidth speed in a variety of units, analogous to the `core::time::Duration` type.
https://github.com/stack-rs/bandwidth
rust
Last synced: 3 months ago
JSON representation
A library for representing bandwidth speed in a variety of units, analogous to the `core::time::Duration` type.
- Host: GitHub
- URL: https://github.com/stack-rs/bandwidth
- Owner: stack-rs
- License: apache-2.0
- Created: 2023-02-08T12:18:28.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-06-07T13:50:48.000Z (about 2 years ago)
- Last Synced: 2024-08-10T23:19:51.595Z (almost 2 years ago)
- Topics: rust
- Language: Rust
- Homepage:
- Size: 40 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Bandwidth
[](https://github.com/stack-rs/bandwidth)
[](https://crates.io/crates/bandwidth)
[](https://docs.rs/bandwidth)
[](https://github.com/stack-rs/bandwidth/blob/main/LICENSE)
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](https://docs.rs/bandwidth).
```rust
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](https://github.com/BobAnkh)
## How to contribute
You should follow our [Code of Conduct](/CODE_OF_CONDUCT.md).
See [CONTRIBUTING GUIDELINES](/CONTRIBUTING.md) for contributing conventions.
Make sure to pass all the tests before submitting your code.
### Contributors
## LICENSE
[Apache-2.0](LICENSE) © stack-rs