File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change 5
5
[](https://docs.rs/bandwidth)
6
6
[ ![ LICENSE Apache-2.0] ( https://img.shields.io/github/license/stack-rs/bandwidth?logo=Apache )] ( https://github.com/stack-rs/bandwidth/blob/main/LICENSE )
7
7
8
- A library for representing bandwidth speed in a variety of units, mimicking the ` core::time::Duration ` struct.
8
+ A library for representing bandwidth speed in a variety of units, mimicking the ` core::time::Duration ` struct.]
9
+
10
+ ## Usage
11
+
12
+ More detailed usage can be found on [ documentation] ( https://docs.rs/bandwidth ) .
13
+
14
+ ``` rust
15
+ use bandwidth :: Bandwidth ;
16
+
17
+ let five_gbps = Bandwidth :: from_gbps (5 );
18
+ assert_eq! (five_gbps , Bandwidth :: from_mbps (5_000 ));
19
+ assert_eq! (five_gbps , Bandwidth :: from_kbps (5_000_000 ));
20
+ assert_eq! (five_gbps , Bandwidth :: from_bps (5_000_000_000 ));
21
+
22
+ let ten_gbps = Bandwidth :: from_gbps (10 );
23
+ let seven_bps = Bandwidth :: from_bps (7 );
24
+ let total = ten_gbps + seven_bps ;
25
+ assert_eq! (total , Bandwidth :: new (10 , 7 ));
26
+ ```
9
27
10
28
## Maintainer
11
29
You can’t perform that action at this time.
0 commit comments