1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#[macro_use]
extern crate error_chain;
mod errors {
error_chain! { }
}
use self::errors::*;
pub struct Bytes(u64);
pub type B = Bytes;
pub struct kB(f64);
pub struct MB(f64);
pub struct GB(f64);
pub struct KiB(f64);
impl From<Bytes> for KiB {
fn from(bytes: Bytes) -> Self {
KiB(bytes.0 as f64 / 1024.0)
}
}
pub struct MiB(f64);
impl From<Bytes> for MiB {
fn from(bytes: Bytes) -> Self {
MiB(bytes.0 as f64 / 1048576.0)
}
}
pub struct GiB(f64);
impl From<Bytes> for GiB {
fn from(bytes: Bytes) -> Self {
GiB(bytes.0 as f64 / 1073741824.0)
}
}